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;

mercredi 10 octobre 2018

How to Switch From PHP 5.6 to PHP 7.2

The PHP 5.6 is set as default version in your system, and you need to switch to PHP 7.2. Run the following commands to switch for Apache and command line.

Apache run:
sudo a2dismod php5.6
sudo a2enmod php7.2
sudo service apache2 restart
Command Line:
sudo update-alternatives --set php /usr/bin/php7.2
sudo update-alternatives --set phar /usr/bin/phar7.2
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.2
sudo update-alternatives --set phpize /usr/bin/phpize7.2
sudo update-alternatives --set php-config /usr/bin/php-config7.2
that's all :)