composer install autoload failed - composer-php

On the first composer install command ( just after the clone on project ), I got this error:
Generating autoload files
[ErrorException]
Undefined index: vulnerabilities
With some more verbosity, I get this :
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
Downloading https://flex.symfony.com/p/symfony,polyfill-php80,iv1.22.1,1610038173;jean85,pretty-package-versions,i1.6.0,1612455616;symfony,lock,iv4.2.12,1561965886
[ErrorException]
Undefined index: vulnerabilities
Exception trace:
() at /var/www/bridge-landwehr/vendor/symfony/flex/src/Downloader.php:144
Composer\Util\ErrorHandler::handle() at /var/www/bridge-landwehr/vendor/symfony/flex/src/Downloader.php:144
Symfony\Flex\Downloader->getRecipes() at /var/www/bridge-landwehr/vendor/symfony/flex/src/Flex.php:589
Symfony\Flex\Flex->fetchRecipes() at /var/www/bridge-landwehr/vendor/symfony/flex/src/Flex.php:313
Symfony\Flex\Flex->update() at /var/www/bridge-landwehr/vendor/symfony/flex/src/Flex.php:299
Symfony\Flex\Flex->install() at n/a:n/a
call_user_func() at phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:176
Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:96
Composer\EventDispatcher\EventDispatcher->dispatchScript() at phar:///usr/local/bin/composer/src/Composer/Installer.php:324
Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/InstallCommand.php:121
Composer\Command\InstallCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:245
Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:835
Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:185
Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:258
Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:117
Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:104
Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:56
require() at /usr/local/bin/composer:24
It seems to be a problem with symfony/flex. Because when I check the file download : https://flex.symfony.com/p/symfony,polyfill-php80,iv1.22.1,1610038173;jean85,pretty-package-versions,i1.6.0,1612455616;symfony,lock,iv4.2.12,1561965886, where is no key "vulnerabilities"
If I re-run the composer install a second time there is no problem. Did someone know why ?
composer version in 1.8.0

I had the same error suddenly for no apparent reason. I tried finding the culprit, but it started taking too long.
I fixed it by upgrading packages.
1-Try upgrading composer to from version 1 to version 2 (2.0.13 worked for me).
//Check your composer version
composer -v
2-Make sure to fully upgrade to Symfony 4.4.* (In my case, I was in version 4.2-4.3 for some components) Follow these steps: https://symfony.com/doc/current/setup/upgrade_minor.html
Symfony flex version 1.12.2 worked for me with symfony 4.4
I previously thought 4.4 would be breaking for me but it was not. My error was to previously try to upgrade to 4.3. Skip that one!
4.4 Is also supported until november 2022 unlike other minor versions in V4.

Related

inheritance of ArrayAccess: Uncaught ErrorException: Collection::offsetExists($key)

NB: Local server PHP Version 8.1.4, laravel project inside composer.json file have "php": "^7.2.5", version & "laravel/framework": "^7.0"
PHP Fatal error: During inheritance of ArrayAccess: Uncaught ErrorException: Return type of Illuminate\Support\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
error displaying below like this :
That's a php version issue. Upgrade laravel or downgrade PHP. This article covers how to downgrade the PHP version so it matches the Laravel Version.
https://bytexd.com/fix-laravel-return-type-of-illuminatesupportcollectionoffsetexistskey/
in your composer.json update line
"php": "^7.3",
to
"php": "^7.3|^8.1",
and run composer update
You would need to upgrade your Laravel Framework version to at least version 8 and it's dependencies using composer.
Reference: https://laravel.com/docs/8.x/releases
Or if you want to postpone it, you would need to add #[\ReturnTypeWillChange] before declaring every function that throws the error. This is highly not advisable.
P.S. If you updated your PHP version you would have to change the PHP version in composer to the one used, in your case it should be "php": "^8.1.4"
In my case, using a mac, turns out my php version was 8.1 which somehow is not compatible with laravel version 7. Tho most of these answers are correct, but they did not fix my issues. I followed these steps (if brew is installed):
brew unlink php#8.1
brew link php#8.0 or lower
Reference How can I easily switch between PHP versions on Mac OSX?
run "composer update" on your project directory and it will work .

laravel old version is not supporting php 8.0.8

I have installed php 8.0.8 on my local computer. Laravel new projects work perfect. But when I try to run Old projects it shows me error. When I try to run command
composer install
It gives me the error below:
Problem 1
- jeremy-dunn/php-fedex-api-wrapper is locked to version 5.0.1 and an update of this package was not requested.
- jeremy-dunn/php-fedex-api-wrapper 5.0.1 requires ext-soap * -> it is missing from your system. Install or enable PHP's soap extension.
To enable extensions, verify that they are enabled in your .ini files:
- C:\xampp\php\php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
When I run:
composer dump-autoload
It shows this error:
Generating optimized autoload files Class App\Http\Controllers\Vendor\OrderController
located in C:/Users/Muhammad Adnan/Downloads/test-upwork-master/spree-retail/app\Http\Controllers\temp\OrderController.php does not comply with psr-4 autoloading standard. Skipping.
Class App\Http\Resources\profile\AddressesResponse located in C:/Users/Muhammad Adnan/Downloads/test-upwork-master/spree-retail/app\Http\Resources\Profile\AddressesResponse.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Foundation\ComposerScripts is not autoloadable, can not call post-autoload-dump script
> #php artisan package:discover --ansi
Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found in C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\bootstrap\app.php:14
Stack trace:
#0 C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\artisan(20): require_once()
#1 {main}
thrown in C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\bootstrap\app.php on line 14
PHP Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found in C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\bootstrap\app.php:14
Stack trace:
#0 C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\artisan(20): require_once()
#1 {main}
thrown in C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\bootstrap\app.php on line 14
Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
Unfortunately, older versions of Laravel doesn't not support newer versions of PHP. Laravel 6 is the minimal version for PHP 8.0 support (and it is already pretty old from a web development perspective).
Of course, this is for a fresh installation, you might have code in your project that is also not PHP 8.0 compatible.
About this error:
Problem 1
- jeremy-dunn/php-fedex-api-wrapper is locked to version 5.0.1 and an update of this package was not requested.
- jeremy-dunn/php-fedex-api-wrapper 5.0.1 requires ext-soap * -> it is missing from your system. Install or enable PHP's soap extension.
The problem will be easy to fix, just install the soap extension. You seem on Windows so it should already installed but disabled.
You will have to uncomment ;extension=soap.dll in your php.ini file (or maybe in the ext directory located in your php directory, it depends).
There will probably be other extensions required but disabled, to get a full list execute composer check.
This is what is preventing composer from installing your dependencies (which lead Uncaught Error: Class "Illuminate\Foundation\Application" not found in to when you are calling composer dump-autoload).
I searched out and found a solution regarding this issue. Only single command is the solution
Note: Don't update composer.
composer install --ignore-platform-reqs

How to convert laravel 7.1.3 projects to run on laravel 8.0.0? [duplicate]

after updating my mac to php 8 laravel app stopped working, this is the error I'm getting:
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/.../Sites/.../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 871
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/.../Sites/.../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 945
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/.../Sites/.../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 871
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/.../Sites/.../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 945
I've tried to fix the issue by investigating the code with no luck
THE SOLUTION
As explained here latest version of laravel 6, 7 and 8 has made changes required for php 8. all you have to do is:
1- add php 8 to your composer.json (I've kept v7.4 just in case production server does not support php 8 yet)
"php": "^7.4|^8.0",
2- to run composer update to update your laravel to the latest version
composer update
3- make sure update the following libraries since they exist in all laravel applications
PHP to php:^8.0
Faker to fakerphp/faker:^1.9.1
PHPUnit to phpunit/phpunit:^9.3
4- check for any other library which needs to be updated, contribute if they haven't supported php 8. but you should be good to go with most of the libraries since they have active contributors.
EXPLAINING THE PROBLEM
as described here
PHP 8 introduces several improvements in PHP type systems such as the introduction of Union Types, mixed type, and a few more.
With these changes, certain methods in Reflection API's
ReflectionParameter yield incorrect results.
In PHP 8, the following methods from ReflectionParameter class is
deprecated:
ReflectionParameter::getClass()
ReflectionParameter::isArray()
ReflectionParameter::isCallable()
ReflectionParamter::getType() is the recommended way to replace the
deprecated methods. This method is available in PHP 7.0 and later.
Check your php version in your virtual machine(xampp or server).
php --version
Is that version PHP 8 ? Am I right? That's the cause of the problem:
PHP 8 introduces several improvements in PHP type systems such as the introduction of Union Types, mixed type, and a few more.
With these changes, certain methods in Reflection API's ReflectionParameter yield incorrect results.
In PHP 8, the following methods from ReflectionParameter class is deprecated:
ReflectionParameter::getClass()
ReflectionParameter::isArray()
ReflectionParameter::isCallable()
ReflectionParamter::getType()
Downgrade your php version to 7.4 and your Laravel app works like a charm!
I had similar issue. But I had already run brew update and brew cleanup before I noticed the issue. What I did:
I noticed this error from brew cleanup:
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/node
Target /usr/local/bin/node
already exists. You may want to remove it:
rm '/usr/local/bin/node'
To force the link and overwrite all conflicting files:
brew link --overwrite heroku-node
I ran the commands:
brew link --overwrite composer
composer upgrade
composer update
That's what worked for me
If you're using valet you should do the followings:
Downgrade from php8+ to php7.4 valet isolate php#7.4
Then run composer update using valet valet composer update

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",

Composer CreateProcess Error Code 0 during Zend Framework 2 installation

I'm stuck at the first step of the Zend Framework 2 Getting Started guide.
My steps:
I downloaded end extracted the newest version of composer to
c:/xampp/composer/composer.phar
I ran php composer.phar
self-update just in case.
I ran php composer.phar create-project
--repository-url="http://packages.zendframework.com" zendframework/skeleton-application ../htdocs/zf2-tutorial like it is
stated in the guide.
This is where I get this error message:
Fatal error: Uncaught exception 'ErrorException' with message 'proc_open():
CreateProcess failed, error code - 0' in phar://C:/xampp/htdocs/ZendSkeletonApplication/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php on line 1013
I will add the full call Stack in the end of the question.
What I aready tried:
The Guide in the answer to this question leads to the same error:
Installing Zend Framework 2 on XAMPP in Windows
I freed my RAM to ~2,7 Gb avalable space
I tried different installation guides
I ran the CLI with admin rights
My setup:
Windows 8
PHP 5.4.4
Composer version d017e3f2096dda7194600a76bc7328808811c8da
Server version: Apache/2.4.2 (Win32)
My questions:
Any suggestions to how to solve this problem?
Can I install ZF2 without using composer?
Call Stack:
0.0150 232360 1. {main}() C:\xampp\htdocs\ZendSkeletonApplication\composer.phar:0
0.0155 231416 2. require('phar://C:/xampp/htdocs/ZendSkeletonApplication/composer.phar/bin/composer') C:\xampp\htdocs\ZendSkeletonApplication\composer.phar:15
0.1072 2023984 3. Composer\Console\Application->run() phar://C:/xampp/htdocs/ZendSkeletonApplication/composer.phar/bin/composer:43
0.1199 2234448 4. Symfony\Component\Console\Application->run() phar://C:/xampp/htdocs/ZendSkeletonApplication/composer.phar/src/Composer/Console/Application.php:83
0.2064 3173376 5. Composer\Console\Application->renderException() phar://C:/xampp/htdocs/ZendSkeletonApplication/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:128
0.2368 3201408 6. Symfony\Component\Console\Application->renderException() phar://C:/xampp/htdocs/ZendSkeletonApplication/composer.phar/src/Composer/Console/Application.php:163
0.2369 3202256 7. Symfony\Component\Console\Application->getTerminalWidth() phar://C:/xampp/htdocs/ZendSkeletonApplication/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:731
0.2369 3202272 8. Symfony\Component\Console\Application->getTerminalDimensions() phar://C:/xampp/htdocs/ZendSkeletonApplication/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:797
0.2374 3202472 9. Symfony\Component\Console\Application->getConsoleMode() phar://C:/xampp/htdocs/ZendSkeletonApplication/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:827
0.2374 3203768 10. proc_open() phar://C:/xampp/htdocs/ZendSkeletonApplication/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:1013
0.2402 3204624 11. Composer\Util\ErrorHandler::handle() phar://C:/xampp/htdocs/ZendSkeletonApplication/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:1013
Surprisingly, it was much easier than I thought:
git clone git://github.com/zendframework/ZendSkeletonApplication.git --recursive
It installed the framework under ./vendor/ZF2/.

Resources