1 min read
Last update: November 28, 2021

Switch between PHP versions


If you want to switch PHP CLI version, follow these steps

If you just want to use another PHP version pour a Virtual host, like a old Drupal app, just change PHP version in NGINX conf.
sudo update-alternatives --config php

You will have a menu to choose PHP CLI version

  Selection    Path             Priority   Status
* 0            /usr/bin/php7.4   74        auto mode
  1            /usr/bin/php7.2   72        manual mode
  2            /usr/bin/php7.3   73        manual mode
  3            /usr/bin/php7.4   74        manual mode

After change PHP version restart NGINX and restart PHP version you choose

sudo service nginx restart
# example if you choose php7.2
sudo service php7.2-fpm restart


Concat variable into string:


$basic = "lists/".$list_test_id."/contacts"

$improved = "lists/${list_test_id}/contacts"


Error on function where everything is okay about syntax.

Type declaration

Check return data like:


public function getData : Collection
    $data = Data::all();
    return $data;

It will works only with PHP 7.3, maybe NGINX VHost use a PHP version too old.