Fatal error: Interface 'Psr\Container\ContainerInterface' not found in - php

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
{
...
}

At my job we had 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 removing the vendor folder alone didn't help us. First we needed to clear the composer cache using this command:
composer clearcache
and then we removed the vendor folder and ran composer install, everything went fine. I hope this solution helps someone.

I had the same issue.
Still investigating, but what I discovered so far is that, running composer install --no-dev [...], I have the package psr/container in vendor/psr/container in vendors, but 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), line missing in vendor/composer/autoload_psr4.php.
For the time being, I fixed it including dev dependencies, until I figure out the real fix.

Related

Uncaught Error: Class 'ComposerAutoloaderInit' not found

After attempting to remove and reinstall a package I'm getting this new error when I try to include('vendor/autoload.php');
Fatal error: Uncaught Error: Class >'ComposerAutoloaderInit7b3c839efeba468a3d595a365ceb8e89' not found in >mypath\vendor\autoload.php:7 Stack trace: #0 mypath\mypage.php(2): include() >#1 {main} thrown in mypath\vendor\autoload.php on line 7
I've tried running composer clearcache before and after reinstalling the package. I deleted C:/Users/MyUsername/AppData/Roaming/Composer and even completely uninstalled Composer. After I reinstalled composer and then reinstalled the package, the error message remains.
What am I missing? I feel like it has a hidden cache somewhere that's breaking this.
Your autoloader seems to be on an unfit state.
Just regenerate it.
composer dump-autoload
If this doesn't work (although it should), simply remove the whole vendor directory, and run composer install again.
Clearing composer's cache has no effect on this, since this is only the one used by composer to avoid downloading files all over again, not a project level cache.

Laravel won't load class

I'm trying to use the following library, this.
It all seems pretty use but doesn't seem to work for me. I've added the stuff the the composer.json and I also updated the app.php. Then I ran composer dump-autoload in the laravel directory.
I still seem to be getting the same error..
FatalErrorException in ProviderRepository.php line 146:
Class 'Invisnik\LaravelSteamAuth\SteamServiceProvider' not found
Try to install this package by this command:
composer require invisnik/laravel-steam-auth
You will install the latest version of current package and update your composer.json, composer.lock and autoload files.

Class 'League\Glide\ServerFactory' is not found [duplicate]

After attempting to remove and reinstall a package I'm getting this new error when I try to include('vendor/autoload.php');
Fatal error: Uncaught Error: Class >'ComposerAutoloaderInit7b3c839efeba468a3d595a365ceb8e89' not found in >mypath\vendor\autoload.php:7 Stack trace: #0 mypath\mypage.php(2): include() >#1 {main} thrown in mypath\vendor\autoload.php on line 7
I've tried running composer clearcache before and after reinstalling the package. I deleted C:/Users/MyUsername/AppData/Roaming/Composer and even completely uninstalled Composer. After I reinstalled composer and then reinstalled the package, the error message remains.
What am I missing? I feel like it has a hidden cache somewhere that's breaking this.
Your autoloader seems to be on an unfit state.
Just regenerate it.
composer dump-autoload
If this doesn't work (although it should), simply remove the whole vendor directory, and run composer install again.
Clearing composer's cache has no effect on this, since this is only the one used by composer to avoid downloading files all over again, not a project level cache.

class 'Former\FormerServiceProvider' not found - Laravel

i'm trying to install the anahkiasen/former package once again but it won't work. The funny thing is, I downloaded it about a weak ago and it was working perfectly. My code if finished and use's this former package. I tried to install a new package a half hour ago and since this the former class isn't found anymore.
Like I mentioned it, it was working perfectly before, but since I did a composer update it doesn't work.
Well I did what they said over here:
https://github.com/formers/former/wiki/Getting-started
first I run this::
composer require anahkiasen/former:4.0.*#dev
then a composer update
after the update I add this in my config/app.php provider section:
Former\FormerServiceProvider::class,
and this in the alias section:
'Former' => 'Former\Facades\Former',
I tried it but it still doesn't work. Just getting
Class 'Former\FormerServiceProvider' not found
as an output
I removed the package I wanted to install before and found another way.. But the problem with the former class is still there.
Thanks for any help!
Terminal outputs:
/var/www/laravel# php composer.phar require anahkiasen/former
gives:
Using version ^4.0 for anahkiasen/former
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
-------- then I added the provider/alias --- after this:
composer update --no-scripts
gives
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
composer dump-autoload
gives of course:
Generating autoload files
/var/www/laravel/logs# php artisan config:publish anahkiasen/former
gives:
PHP Fatal error: Class 'Former\FormerServiceProvider' not found in /var/www/laravel/logs/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Former\FormerServiceProvider' not found
note that I changed the directory in the last command
Let's start from the beginning.
Follow below steps:-
1) Run below command in terminal:-
composer.phar require anahkiasen/former
2) It'll ask you for the version, type dev-master
3) Add Former's service provider to your Laravel application in app/config/app.php. In the providers array add :
'Former\FormerServiceProvider',
Add then alias Former's main class by adding its facade to the aliases array in the same file :
'Former' => 'Former\Facades\Former',
4) run composer update --no-scripts
After that, run composer dump-autoload, and that should work.
If not working then run this command:-
php artisan config:publish anahkiasen/former
Hope it will help you :)

Laravel + git, contributors have different environment

Me and my coworker are trying to use local git repo for our Laravel project.
I am using Ubuntu, with PHP 5.5.9-1ubuntu4.9, and he is using Debian with PHP 5.4.39.
When I pulled his committed version, I get an error when trying to run composer update:
user#ubuntu:/var/www/frontend$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
PHP Fatal error: Class 'Illuminate\Support\Arr' not found in /var/www/frontend/vendor/laravel/framework/src/Illuminate/Support/helpers.php on line 182
Script php artisan clear-compiled handling the post-install-cmd event returned with an error [RuntimeException]
Error Output: PHP Fatal error: Class 'Illuminate\Support\Arr' not found in /var/www/frontend/vendor/laravel/framework/src/Illuminate/Support/helpers.php on line 182
We have vendor folder on git, since not having it isn't an option for us.
I guess the problem is different php versions. Is there a way of setting up php version manually, so composer gets the right dependencies?
you can set php version in composer.json file in require portion
"require": {
"php": ">=5.3.0",
},
The problem was probably this:
User checked in the project, including the vendor folder.
Later vendor somehow got added to .gitignore
Nobody noticed that new files were not being added to the repo and magic made sure everything still worked as it did :D

Categories