Working Gau Frette with file streams

To with Gau Frette (Symfony extension) to be able to perform also stream operations on files, can you get the little scrawny documented Stream wrapper use.

This is configured in the gaufrette.yaml:

    stream_wrapper: ~
            adapter: backup

And can then be z.B. the following mass is a csv. Write file:

$stream = fopen('gaufrette://backup1/datei.csv', 'w+');

fputcsv($stream, [1,2,3]);

Dynamically configure symfony service ID using parameters

If you like in his Depnedency configuration of injection (services.yml) the service injections make dynamically configurable wants about the parameters.yml,

    my_class: 'App\MyClass'

can you do this using the Symfony expression language component do:

composer require symfony/expression-language

Then you can define in the services.yml:

        - '@=service(parameter("my_class"))'

Yii2 versus symfony 4 – a framework comparison

I have long worked with Yii and the symfony framework and want to try the following to explain the differences between the two frameworks from programmers point of view.

Configuration of environments

When you create Web applications is typically at least 2 Environments: The development environment, on which you want to see errors and the live environment, where this should happen. To come test environment to run automated tests and perhaps a staging environment.

Symfony raises the very skillfully, with the .env files and own folders within the configuration folder.

At Yii must the programmers themselves lend a hand, to load the correct configuration, There are only from home 3 (dev, Prod, test) Vorgsehen environments, then it is confusing. more…

Twig extension to sort of entities by DateTime property

If one wants to sort a collection of doctrine in the template after a time stamp (createdAt the example), before actually make this.

If this is not possible, e.g.. in the Sonata Admin Bundle, then you can use this twig extension:

{% foo| sortByCreatedAt('asc') %}

Twig extension code:


namespace App\Twig;

use App\Entity\Tag;
use Doctrine\ORM\PersistentCollection;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;

class AppExtension extends AbstractExtension
    public function getFilters()
        return array(
            new TwigFilter('sortByCreatedAt', array($this, 'sortByCreatedAt')),

     * @param PersistentCollection $objects
     * @return mixed
    public function sortByCreatedAt($objects, $direction = 'asc')
        $objects = $objects->toArray();
        usort($objects, function ($a, $b) use($direction) {
            if ($direction === 'asc') {
                return $a->getCreatedAt() >  $b->getCreatedAt();
            } elseif ($direction === 'desc') {
                return $a->getCreatedAt() <  $b->getCreatedAt();
            } else {
                throw new \Exception('unknown sort direction');

        return $objects;

Strato und MySQL: General error: 1709 Index column size too large. The maximum column size is 767 bytes.

A customer following error message was shown to me, When I tried the database have symfony to create:

General error: 1709 Index column size too large. The maximum column size is 767 bytes.

This is because, the Strato strange setting in their managed hosting packages such as z.B. has the STRATO PowerWeb. Strato unfortunately won't change this setting, but you can in symfony in the doctrine.yaml (config.YAML) change the charset, Symfony works well on a Strato Server:

        # configure these for your database server
        driver: 'pdo_mysql'
        server_version: '5.6'
        charset: utf8
            charset: utf8
            collate: utf8_general_ci

Symfony security passwords hash with the PasswordEncoder

The PasswordEncoder the symfony framework secure hashes of passwords in the database is very well suitable also in future to save and configure Central.

The SecurityBundle must if necessary. to be installed:

composer require symfony/security-bundle

Putting this in the security.yaml, you want to use what hashing algorithm for which entity:

        App\Entity\User: bcrypt

The entity must implement the UserInterface: more…

Symfony 3 Establish a test database for integration testing

In Symofny it is called automatically when you run tests app/config/parameters_test.yml loaded.
There, another database should then be specified, for simplicity sake with the same database user:

database_host: same_as_dev
database_port: same_as_dev
database_name: test_db
database_user: same_as_dev
database_password: same_as_dev

Then following commands must be executed on the console:
Clear cache:
am PHP / console cache:clear –env = test

Create database
am PHP / console doctrine:database:create –env = test

Create tables
HP am / console doctrine:schema:update –env = test –force

Then can fixtures are loaded and integration tests are written.


Syfmony 3.3. – How to injeziert a repository as a service using dependency injection

In symfony 3 is by default the EntityManager injected, then get the corresponding repository available.

Most of the time, but just a repository is required and to bloat the code and tests.

There is a simple way in the configuration to create a service from a repository:
 class: 'AppBundle\Repository\MyEntity'
 factory: 'Doctrine\ORM\EntityManagerInterface:getRepository'
 arguments: ['AppBundle\Entity\MyEntity']

Project: baby

The just completed project baby deals with the issues relating to the development of the own child:

  • How great my child be in x years
  • My child is like in x years
  • Is my child too hard or too thin
  • What dress size is wear it when?

The Web page is to help parents find out, When you need to buy what dress size, the approaching winter/summer home to have the appropriate.

Parents can thus einschätzne, If the child is too thin or too thick for your age/size/weight ratio.

The following technologies were used for the realization:

Symfony 3, Docker, MySQL, PHP, GIT, Google material design, Amazon AWS

Amazon automatic price adjustment tool

I developed a tool just for a customer, with the one the prices of own goods at Amazon can automatically adapt. In the competition to Goth are determined analyzes reliability and therefore a fair price condition of the product and seller for the goods. There are all the data, about the API are available for the determination of price with used, as e.g.. Seller feedback (Reviews of the dealer), whether Amazon itself sent, Shipping time and much more.

The tool compares the rates between the various Amazon optional platforms in Europe (DE, UK, IT, IT, FR) Platforms but also outside Europe, like Japan or America and händelt the different currencies.

The result can be sent directly to Amazon via the API and the prices will be immediately updated.

Amazon Preisanpassung

Screenshot Preisanpassungs Tool


The application is in PHP with symfony 3 written and has a front end with Twitter bootstrap 3 and a MySQL database. There's also a vagrant environment for developing with PHP7. 1 and nginx. Be carried out can the whole thing with a simple XAMPP environment or vagrant virtual box at the customer locally on a PC.

If you are also interested in such a tool, allows you to Contact.