Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Fatal error: Default value for parameters with a class type hint can only be NULL in /usr/share/php/Symfony/Component/

I cloned new project from github which has following dependencies:

"require": {
    "php": ">=5.6.4",
    "backpack/base": "^0.7.16",
    "backpack/crud": "^3.2",
    "backpack/permissionmanager": "^2.1",
    "barryvdh/laravel-cors": "^0.9.2",
    "laravel/framework": "5.4.*",
    "laravel/passport": "^2.0",
    "laravel/tinker": "~1.0",
    "league/fractal": "^0.16.0"
},

When I am running composer update or any other command, it shows the error as follows:

PHP Fatal error: Default value for parameters with a class type hint can only be NULL in /usr/share/php/Symfony/Component/Console/Application.php on line 85

Fatal error: Default value for parameters with a class type hint can only be NULL in /usr/share/php/Symfony/Component/Console/Application.php on line 85

I am currently using PHP 5.6. What could be the problem?

like image 333
Dipak Rathod Avatar asked Oct 23 '25 11:10

Dipak Rathod


2 Answers

Your Composer Version is not working with php 5.6

To bring it to work, use it as composer.phar

See https://getcomposer.org/download/

Download Composer Latest: v2.0.9

To quickly install Composer in the current directory, run the following script in your terminal. To automate the installation, use the guide on installing Composer programmatically.

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
like image 122
Wolfgang Blessen Avatar answered Oct 26 '25 02:10

Wolfgang Blessen


I deleted the composer (which was installed when I was using PHP7) and installed it again. It is solved my problem.

Ubuntu 20.04, PHP5.6

  1. type composer
  2. sudo rm -r /usr/local/bin/composer (or sudo apt remove composer)
  3. sudo rm -r ~/.cache/composer
  4. sudo rm -r ~/.local/share/composer
  5. sudo rm -r ~/.config/composer
  6. sudo apt install curl php5.6-cli
  7. curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
like image 40
hamid imomov Avatar answered Oct 26 '25 00:10

hamid imomov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!