Category: symfony-3.4

Correct type hint error thrown by PHPStan on UserInterface in Symfony project

I’ve recently started using PHPStan (version 0.12.19) on a Symfony 3.4 project but I’m getting an error which seems like it should have been simple to resolve but I’m struggling to figure out. Currently running at level 7. Here’s the…

Change sonata media upload directory programatically

I have a multisite using the package prodigious/symfony-multisite-bundle and each site has its own folder on images upload through sonata media. Uploading the image through the admin interface save the images in the right folder. filesystem: local: directory: “%kernel.root_dir%/../web/uploads/%kernel.name%/media” #non-flex…

Custom option in EntityType (Symfony 3)

I have this code: $form = $this->createFormBuilder() ->add(‘client_id’, EntityType::class, [ ‘class’ => ‘AppBundle:WebClient’, ‘query_builder’ => function (EntityRepository $er) { return $er ->createQueryBuilder(‘w_client’) ->where(‘w_client.is_removed = 0’); }, ‘choice_label’ => function ($w_client) { return $w_client->getCompanyName(); }, ]) ->getForm(); How can I add…

Symfony cache:clear when building a docker container or when running it first time?

I’m containerizing a symfony-3 application within a docker. Currently, I am copying a complete parameters.yml in function of a build ARG, so I can make 3 different builds: devel, pre and prod with 3 different config files. I already know…