vendredi 18 septembre 2020

Since symfony/dependency-injection 5.1: The "Symfony\Component\DependencyInjection\ContainerInterface" autowiring alias is deprecated. [FIXED] [RESOLVED]

 May be a lot of you, have seen this deprecation message while the migration to symfony 5.1.
So here the solution:

Symfony is really discouraging the injection of the global container. To fix the message, all you need to do is to explicitly define the ContainerInterface alias as the Symfony Profiler recommanded you:

# services.yml or yaml
    Symfony\Component\DependencyInjection\ContainerInterface: '@service_container'

mercredi 4 décembre 2019

Symfony : Making your Code Follow the Coding Standards

First download the phar file: here
then copy the file in your project racine.
now all to do is to execute the phar file considering the code directory (in my case: 'src'):

cd your-project/
php php-cs-fixer-v2.phar fix -v src

vendredi 28 juin 2019

.htaccess https no www

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]

mardi 5 mars 2019

Ubuntu / Debian: Low Level Formatting

To retrieve the code name (that is, the xxx of / dev / xxx) from your hard disk, do:

sudo fdisk -l

You will see the list of hard drives and their partitions ... Take for example the hard disk / dev / sda, which you want to format.
dd if=/dev/zero of=/dev/sda

jeudi 21 février 2019

Solution for [ERROR: for redis-commander Cannot start service redis-commander: driver failed programming external connectivity on endpoint]

I solved this issue by running the following:

Error :
ERROR: for redis-commander  Cannot start service redis-commander: driver failed programming external connectivity on endpoint docker_redis-commander_1 (2631d041f6bf20894f47c2d3743db4dde7157ac6c441cb061b85538da53a6b71): Error starting userland proxy: listen tcp bind: address already in use
ERROR: Encountered errors while bringing up the project.
solution :
docker stop $(docker ps -a -q); docker rm $(docker ps -a -q); docker volume rm $(docker volume ls -qf dangling=true)
docker network rm $(docker network ls -q)
sudo lsof -nP | grep LISTEN
sudo kill -9 1548
Where on the last line, 1548 was a service that was using port 8081.

mercredi 20 février 2019

Symfony ChoiceType Error Messages

How ChoiceTypes Errors

Interestingly, with the validator form extension the ChoiceType always shows as valid when a form is submitted.

If the ChoiceType field ends up not synchronized, a violation is added with the invalid_message option as its message.

To provide a real, useful error message pass invalid_message to your ChoiceType field. invalid_message_parameters is also useful.

use Symfony\Component\Form\Forms;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
use Symfony\Component\Validator\Validation;
$validator = Validation::createValidator();
$forms = Forms::createFormFactoryBuilder()
    ->addExtension(new ValidatorExtension($validator))
$choices = [
    'One' => 'one',
    'Two' => 'two',
$form = $forms->createBuilder()
    ->add('test', ChoiceType::class, [
        'choices' => $choices,
        'invalid_message' => '"{{ value }}" is not valid. Valid choices: {{ choices }}.',
        'invalid_message_parameters' => [
            '{{ choices }}' => implode(', ', $choices),
$form->submit(['test' => 'three']);
var_dump($form->isValid()); // true
// outputs '"three" is not valid. Valid choices: one, two.
foreach ($form->getErrors(true) as $err) {
    echo $err->getMessage(), PHP_EOL;