Php – Fatal error: Interface ‘Psr\Container\ContainerInterface’ not found in

composer-phplaravelPHP

Two weeks ago I didn't have any problem, but today this appears when I put composer install

Loading composer repositories with package information

Installing dependencies (including require-dev) from lock file

Nothing to install or update

Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postAutoloadDump
PHP Fatal error: Interface 'Psr\Container\ContainerInterface' not found in /opt/lampp/htdocs/nuevodirectorio/ClinicaLaravel/vendor/laravel/framework/src/Illuminate/Contracts/Container/Container.php on line 8

Fatal error: Interface 'Psr\Container\ContainerInterface' not found in /opt/lampp/htdocs/nuevodirectorio/ClinicaLaravel/vendor/laravel/framework/src/Illuminate/Contracts/Container/Container.php on line 8

Here is part of the code of Container.php:

<?php
  namespace Illuminate\Container;

  use Closure;
  use Exception;
  use ArrayAccess;
  use LogicException;
  use ReflectionClass;
  use ReflectionParameter;
  use Illuminate\Support\Arr;
  use Illuminate\Contracts\Container\BindingResolutionException;
  use Illuminate\Contracts\Container\Container as ContainerContract;

  class Container implements ArrayAccess, ContainerContract
  {
   ...
  }

Best Answer

At my job we have the same problem. In our case, there was a psr/container file causing a conflict, but this file was in the composer global cache, so remove the vendor folder doesn't help us. The solution we found was to clear the composer cache using this command:

composer clearcache

then we remove the vendor folder and run composer install, everything goes fine. I hope this solution help someone.