Fatal error: Default value for parameters with a class type hint can only be NULL in PHP - laravel-5

I am running PHP 5.6 & Laravel 5.6 version project. When I clone it from github repo & run "composer install or composer update". It throws me following error.
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
Is it the problem with dependencies?

The laravel version number is unrelated to the minimum php version required. Laravel 5.6 requires php 7.1.3 or greater
https://laravel.com/docs/5.6#server-requirements

Related

ReflectionClass $concrete is empty or null after upgrade to php8.0.8

Running php artisan passport:install after upgrading from php7.4 to php8.1 throws:
Class "" not found error
I have tried to bypass this error by checking for isClass before passing $concrete value to ReflectionClass method in Container.php, but this later lead to:
Type error: Laravel\Passport\Console\ClientCommand::handle(): Argument #1 ($clients) must be of type Laravel\Passport\ClientRepository, null given
Where is this empty value comes from when run php artisan passport:install? Where is the ReflectionClass get the list of class to check from?
Never change any code of the vendor because after a composer update all your codes will disappear and rollback to the original.
When you upgrade your Laravel version, you need to do
composer install
composer dump-autoload -o
to make sure all packages are consistent with your new version.
Thank you matiaslauriti and MamaD. I found the update for the Container package here: https://github.com/illuminate/container. Hope this can help someone else.

PHP Fatal error: Class UpdateHelper\ComposerPlugin contains 2 abstract methods in laravel

I want to install laravel on my windows but getting below error
Using below command install laravel
composer create-project --prefer-dist laravel/laravel:^7.0 learning-app
But getting below error in command prompt after run the composer command
PHP Fatal error: Class UpdateHelper\ComposerPlugin contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Composer\Plugin\PluginInterface::deactivate, Composer\Plugin\PluginInterface::uninstall) in C:\xampp\htdocs\vendor\kylekatarnls\update-helper\src\UpdateHelper\ComposerPlugin.php on line 11
Trying all the commands like composer update but not getting any success.
My php version PHP 7.3.27
Anyone have idea how to solve then let me know
You're trying to install the laravel framework locked at a version released more than 2 years ago, is there a reason for this?
Also, what is the version of your composer (run composer --version)? If you're at the version 2 try downgrading to v1 and try again with the same command, if you really want the 7.0 version of Laravel (or simply install the newest version of the framework).

Laravel - compact(): Undefined variable: operator in Builder.php

I have PHP version-7.3 installed in my system and Laravel-5.8. When I tried to rub composer install or composer update on an old Project with Laravel-5.4 and PHP Version-5.6.4, I got this error shown below:
In Builder.php line 1229:
compact(): Undefined variable: operator
Script php artisan optimize handling the post-install-cmd event returned with error code 1
Then, when I tried to run the application, I got this error page as shown on the screen:
I tried to run:
php artisan cache:clear
and
composer update
but the problem is still there.
How do I get it resolved?
Thank you.
It looks like this issue was fixed in Laravel 5.5 according to this post: https://github.com/laravel/framework/issues/26936#issuecomment-449479336
Since Laravel 5.4 is no longer supported, your best option might be to upgrade. You can find a list of the currently supported versions here: https://laravel.com/docs/releases
The minimal upgrade that should still fix the error would be 5.4 to 5.5. The instructions can be found here: https://laravel.com/docs/5.5/upgrade#upgrade-5.5.0 (please note that support for 5.5 has also ended, but it might still fix your bug). This would also require you to switch the project to PHP 7.0.0 or greater.
If:
You can't upgrade for whatever business/team related reason and
Are sure that the Homestead box is running the correct version of PHP (7.2 or lower based on the answer given here) and yet
are still getting this error,
explicitly define the PHP version on the Homestead.yaml file. This should be done on the sites property as such (each is a new line, of course):
map: test.appp
/home/vagrant/code/test/public
php: "7.1"

Getting error when a project developed in Laravel 5.0 & PHP 5.6 version version, trying to run in PHP 7.2 version

When I set up the Laravel 5.0 version project in PHP 7.2 I am getting following error. Please help me how to run this in PHP 7.2 version or is there any other way.
ErrorException in EncryptionServiceProvider.php line 16: Use of
undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128'
(this will throw an Error in a future version of PHP)

Laravel CLI fails to create new app due to Cannot use lexical variable $eventName as a parameter name

After successful installation of Laravel's install tool using composer using composer global require "laravel/installer" command, the first attempt to create an application by running laravel new app-name fails with the following output, any advice will be appreciated :)
Crafting application...
PHP Fatal error: Cannot use lexical variable $eventName as a parameter name in /Users/ABN/.composer/vendor/guzzlehttp/guzzle/src/Event/Emitter.php on line 48
PHP Stack trace:
PHP 1. {main}() /Users/ABN/.composer/vendor/laravel/installer/laravel:0
PHP 2. Symfony\Component\Console\Application->run() /Users/ABN/.composer/vendor/laravel/installer/laravel:13
PHP 3. Symfony\Component\Console\Application->doRun() /Users/ABN/.composer/vendor/symfony/console/Application.php:126
PHP 4. Symfony\Component\Console\Application->doRunCommand() /Users/ABN/.composer/vendor/symfony/console/Application.php:195
PHP 5. Laravel\Installer\Console\NewCommand->run() /Users/ABN/.composer/vendor/symfony/console/Application.php:878
PHP 6. Laravel\Installer\Console\NewCommand->execute() /Users/ABN/.composer/vendor/symfony/console/Command/Command.php:259
PHP 7. Laravel\Installer\Console\NewCommand->download() /Users/ABN/.composer/vendor/laravel/installer/src/NewCommand.php:52
PHP 8. GuzzleHttp\Client->get() /Users/ABN/.composer/vendor/laravel/installer/src/NewCommand.php:125
PHP 9. GuzzleHttp\Client->createRequest() /Users/ABN/.composer/vendor/guzzlehttp/guzzle/src/Client.php:125
PHP 10. GuzzleHttp\Client->getEmitter() /Users/ABN/.composer/vendor/guzzlehttp/guzzle/src/Client.php:115
PHP 11. spl_autoload_call() /Users/ABN/.composer/vendor/guzzlehttp/guzzle/src/Event/HasEmitterTrait.php:15
PHP 12. Composer\Autoload\ClassLoader->loadClass() /Users/ABN/.composer/vendor/guzzlehttp/guzzle/src/Event/HasEmitterTrait.php:15
PHP 13. Composer\Autoload\includeFile() /Users/ABN/.composer/vendor/composer/ClassLoader.php:322
Turned out the issue is related to the guzzle version installed on the system.
After seeing similar issue reported around guzzle 5.3 on some other repositories/apps, confirmed my globally installed version by running composer global info guzzlehttp/guzzle and it was 5.3.
Then updating my composer's global installation by running composer global updatesolved the problem, after seeing the update report as shown bellow, running the same laravel new app-name generates the application successfully.
Updating guzzlehttp/guzzle (5.3.0 => 6.2.3): Downloading (100%)
This is related to Guzzle's PHP 7.x incompatibility and this has been fixed in Guzzle >=5.3.1.
The solution is to upgrade your Guzzle by modifying line in your composer.json file to:
"guzzlehttp/guzzle": "~5.3.1",
or:
"guzzlehttp/guzzle": "~5.3#stable",

Resources