laravel 使用 composer install 在 ProviderRepository.php 错误中找不到类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26206217/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 10:15:04  来源:igfitidea点击:

Class not found in ProviderRepository.php error with composer install

phplaravellaravel-4composer-php

提问by user4106707

I'm currently in the process of trying to include this package in my Laravel app: https://github.com/tappleby/laravel-auth-token

我目前正在尝试将这个包包含在我的 Laravel 应用程序中:https: //github.com/tappleby/laravel-auth-token

I included "tappleby/laravel-auth-token": "0.3.*"in composer.json, like this:

我包含"tappleby/laravel-auth-token": "0.3.*"在 composer.json 中,如下所示:

"require": {
    "laravel/framework": "4.2.*",
    "intervention/image": "dev-master",
    "laracasts/flash": "~1.0",
    "laracasts/validation": "1.1.*",
    "tappleby/laravel-auth-token": "0.3.*"
}

And I added 'Tappleby\AuthToken\AuthTokenServiceProvider'and 'AuthToken'=>'Tappleby\Support\Facades\AuthToken','AuthTokenNotAuthorizedException' =>'Tappleby\AuthToken\Exceptions\NotAuthorizedException'to app/config/app.php.

我将'Tappleby\AuthToken\AuthTokenServiceProvider'和添加'AuthToken'=>'Tappleby\Support\Facades\AuthToken','AuthTokenNotAuthorizedException' =>'Tappleby\AuthToken\Exceptions\NotAuthorizedException'app/config/app.php.

Afterwards I ran composer install. This is the way I always added packages, but now I get an error every time: [RuntimeException]
Error Output: PHP Fatal error: Class 'Tappleby\AuthToken\AuthTokenServiceProvider' not found in /var/www/example.com/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 157

后来我跑了composer install。这是我总是添加包的方式,但现在我每次都收到错误:[RuntimeException]
Error Output: PHP Fatal error: Class 'Tappleby\AuthToken\AuthTokenServiceProvider' not found in /var/www/example.com/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 157

回答by Pasan Bhanu Guruge

Goto bootstrap/cachefolder and delete config.php

转到bootstrap/cache文件夹并删除 config.php

Then run

然后运行

composer dump-autoload

回答by Muhammad

As Marcin said you shouldn't use

正如 Marcin 所说,你不应该使用

composer install

but

composer update

Second thing remove all the lines added to app/config/app.php

第二件事删除添加到的所有行 app/config/app.php

First run composer updateafter that put those lines in app/config/app.php

首先运行composer update之后将这些行放入app/config/app.php

Then run php artisan config:publish tappleby/laravel-auth-tokenin your command line

然后php artisan config:publish tappleby/laravel-auth-token在命令行中运行

It should publish your configuration and now you should be able to use the relevant classes

它应该发布您的配置,现在您应该能够使用相关的类

回答by Razor

Order is mandatory, run composer updatethen add the service provider and aliases to app.php

命令是强制性的,运行composer update然后将服务提供者和别名添加到 app.php

回答by Marcin Nabia?ek

You should run:

你应该运行:

composer update

and not

并不是

composer install

When adding new dependency you should always use composer updateto update your project and not composer install

添加新依赖项时,您应该始终使用composer update更新您的项目而不是composer install