简体   繁体   English

Laravel 5.11 Composer更新错误

[英]Laravel 5.11 Composer Update Error

The oriceon-oauth-5-laravel package was installed by my friend and I pulled the code from git. 我的朋友安装了oriceon-oauth-5-laravel软件包,我从git中提取了代码。 I run the command composer update, but it throws the following error 我运行命令作曲家更新,但会引发以下错误

exception 'Symfony\\Component\\Debug\\Exception\\FatalErrorException' with message 'Class 'Artdarek\\OAuth\\OAuthServiceProvider' not found' in /var/www/html/test/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:146 / var / www / html / test / vendor / laravel / framework / src / Illuminate / Foundation / ProviderRepository中的 异常“ Symfony \\ Component \\ Debug \\ Exception \\ FatalErrorException” ,消息为“找不到类'Artdarek \\ OAuth \\ OAuthServiceProvider'” 。 PHP:146

I resolved this temporarily by commenting the service providers and aliases in app.php file. 我通过注释app.php文件中的服务提供商别名来暂时解决此问题。

So,what is the correct way to resolve this issue. 因此,什么是解决此问题的正确方法。 Its happening after installing the packages in laravel 5.11 在laravel 5.11中安装软件包后发生

The problem is, in your config/app.php file, you'll probably see this: 问题是,在您的config/app.php文件中,您可能会看到以下信息:

Artdarek\OAuth\OAuthServiceProvider::class,

in the list of providers. 在提供商列表中。 Since you haven't yet installed that package, the class doesn't exist. 由于您尚未安装该软件包,因此该类不存在。 I think you figured that part out since you said you commented out the providers. 我认为您已经说明了这一点,因为您说过您已经注释掉了提供者。

In composer.json you'll see under scripts: composer.json您将在脚本下看到:

"pre-update-cmd": [
    "php artisan clear-compiled"
],

That means that whenever you run composer update , it first calls php artisan clear-compiled , which loads your config files, which fails because of that missing class. 这意味着,每当您运行composer update ,它都会首先调用php artisan clear-compiled ,它会加载您的配置文件,由于缺少该类而失败。

Two ways to get around it: 解决它的两种方法:

Change the provider to be a quote in strings like they were in Laravel 4: 将提供程序更改为类似于Laravel 4的字符串中的引号:

"Artdarek\OAuth\OAuthServiceProvider",

(that's why nobody really had this problem until Laravel 5 / PHP 5.5 ). (这就是为什么直到Laravel 5 / PHP 5.5之前没人真正遇到过这个问题)。 Or... 要么...

Real solution 真正的解决方案

Just run composer install instead of composer update . 只需运行composer install而不是composer update That's what you should be doing anyway, because whatever your teammate pushed was working with the versions of the libraries that are in composer.lock . 无论如何,这是您应该做的事情,因为您的队友所推动的都是使用composer.lock中的库版本。 So if you run install, it's a) installing known working versions and b) bypassing that php artisan command until after the install is finished. 因此,如果您运行install,则是a)安装已知的工作版本,b)绕过php artisan命令,直到安装完成。

If you really must run composer update , then use it with the --no-scripts flag 如果确实必须运行composer update ,则将其与--no-scripts标志一起使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM