macOS – Install PHP 7.4 and force its use

MacBook Pro affichant du code

Start by installing homebrew /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)” Next, use the following commands brew installs php@7.4 brew link –force php@7.4 brew services start php@7.4 export PATH”/usr/local/opt/php@7.4/bin:$PATH” export PATH”/usr/local/opt/php@7.4/sbin:$PATH” Once this is done, check that the PHP version is correct php -v PHP 7.4.13 (cli) (built: Nov 30 2020 14:46:04) ( NTS ) Copyright (c) … Read more

Categories OSX

Install Xdebug 3 with PhpStorm on macOS

MacBook Pro affichant un éditeur de code

For this example, we will use the Docker installation as well as the Symfony 5 setup described in another article: Article Docker, Symfony 5 Creating an alias for the IP used On MacOS, it is necessary to create an alias for the IP we use. It is common to use the IP: 10.254.254.254 The command … Read more

Symfony4 how to create a custom error page 404

Code sur écran d'ordinateur

You have to start by installing the necessary bundle: compose require symfony/twig-pack When done, create the template error404.html.twig templates/ Bundles/ TwigBundle/ Exception/ Error404.html.twig Example of the error404.html.twig template ‘% extends ‘base.html.twig’ %’ ‘% block body%’ <h1>Page not found</h1> <p> The requested page couldn’t be located. Checkout for any URL misspelling or <a href=”{{ path(‘homepage’) }}”>return … Read more

WordPress – how to install WP-CLI on Ubuntu

MacBook avec code sur un bureau

Start by downloading wp-cli curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar Then give it the right to be executed chmod +x wp-cli.phar Then move it to /usr/local/bin to be able to use the wp command sudo mv wp-cli.phar /usr/local/bin/wp To use the command, simply go into the folder containing the WordPress installation $ wp NAME Wp DESCRIPTION Manage WordPress … Read more

Nginx – phpMyAdmin configuration as location next to a website

MacBook Pro affichant un éditeur de code

To start, install phpmyadmin at the desired location. compose create-project phpmyadmin/phpmyadmin I prefer to use composer, but there are other possibilities Once this is done, go in the folder /etc/nginx. To keep the configuration independent, it is possible to create a snippet. sudo nano snippets/phpmyadmin.conf Then the following configuration must be created. In this example … Read more

Search and replace in the terminal

MacBook Pro affichant un éditeur de code

On Ubuntu it is possible to search and replace a word or phrase with a simple command line sed -i’s/original/new/g’ file.txt Explanation: sed = Stream EDitor -i = in-place (save in the original file) the strings in the command: s = the replacement command original = regular expression for the word to be replaced. new … Read more

Upload multiple files to an entity with Symfony4 and VichUploaderBundle

Code sur écran d'ordinateur

Preparation   To begin with, we need a Product entity as well as a ProductImage entity that will contain the names of the images. To do this, we use the command in our terminal VichUploaderBundle Setup As stated in the Symfony 4 documentation, we will use the VichUploaderBundle Then add the necessary “config/packages/vich_uploader.yaml” configuration file … Read more

Symfony – debug a Twig template with dump()

Code sur écran d'ordinateur

Twig’s {{ dump() }} function is very handy to inspect a variable inside a template. But without the right package installed, the output is unreadable. Here is how to get a clean, collapsible display like this one: Install the DebugBundle The nice output comes from Symfony’s VarDumper component, enabled by the DebugBundle. Install it as … Read more