skip to Main Content

I am created new laravel project, ran composer update and get this error:

> @php artisan package:discover

Fatal error: Uncaught Error: Call to undefined method ComposerRepositoryPlatformRepository::isPlatformPackage() in /var/www/app/vendor/composer/composer/src/Composer/Json/JsonManipulator.php:139
Stack trace:
#0 /var/www/app/vendor/composer/composer/src/Composer/Json/JsonManipulator.php(163): ComposerJsonJsonManipulator->ComposerJson{closure}('php')
#1 [internal function]: ComposerJsonJsonManipulator->ComposerJson{closure}('php', 'matviib/telegra...')
#2 /var/www/app/vendor/composer/composer/src/Composer/Json/JsonManipulator.php(164): uksort(Array, Object(Closure))
#3 /var/www/app/vendor/composer/composer/src/Composer/Json/JsonManipulator.php(119): ComposerJsonJsonManipulator->sortPackages(Array)
#4 /var/www/app/vendor/php-http/discovery/src/Composer/Plugin.php(445): ComposerJsonJsonManipulator->addLink('require', 'php-http/messag...', '*', true)
#5 /var/www/app/vendor/php-http/discovery/src/Composer/Plugin.php(176): HttpDiscoveryComposerPlugin->updateComposerJson(Array, true)
#6 [internal function]: Http in /var/www/app/vendor/composer/composer/src/Composer/Json/JsonManipulator.php on line 139

What is the reason of this error? Looks like some problem inside Composer code so I don’t even know what to do with this.

2

Answers


  1. It seems you’re facing an issue with Composer, likely related to version incompatibility or cache problems. Let’s break down the common causes and solutions:

    1. Composer Version Mismatch

    Older Composer versions might lack features needed by newer packages.
    to fix this you can Upgrade Composer to the latest version:

    composer self-update
    
    1. Composer Cache Issues

    Corrupted cache files can cause errors.To fix this you can clear the Composer cache:

    composer clear-cache 
    
    1. Corrupted Vendor Directory

    Your vendor directory (where dependencies live) might be faulty.You can remove it and the composer.lock file, then reinstall:

    rm -rf vendor
    rm composer.lock
    composer install
    
    1. Package Conflicts

    Your composer.json might list incompatible packages. Carefully examine the dependencies, making sure they work together.

    1. PHP Version Incompatibility

    Your PHP version might not match the requirements of your packages.
    Check your PHP version:

    php -v
    

    Upgrade PHP if needed, or adjust package versions in composer.json to match your PHP.

    Preventing Future Issues

    Keep Composer Updated: Regularly run composer self-update to get the latest features and bug fixes.
    Use composer.lock: Lock dependencies to ensure consistency across environments.

    Login or Signup to reply.
  2. Follow these steps

    1. composer self-update
    2. composer clear-cache
    3. rm -rf vendor/
    4. composer install
    5. composer outdated
    6. composer update
    7. php artisan package:discover
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search