Laravel 5.11 Composer更新错误 [英] Laravel 5.11 Composer Update Error

查看:99
本文介绍了Laravel 5.11 Composer更新错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的朋友安装了oriceon-oauth-5-laravel软件包,我从git中提取了代码.我运行命令作曲家更新,但会引发以下错误

The oriceon-oauth-5-laravel package was installed by my friend and I pulled the code from git. I run the command composer update, but it throws the following error

异常'Symfony \ Component \ Debug \ Exception \ FatalErrorException',并在/var/中显示消息未找到类'Artdarek \ OAuth \ OAuthServiceProvider'" www/html/test/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:146

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

我通过注释 app.php 文件中的服务提供商别名暂时解决了此问题.

I resolved this temporarily by commenting the service providers and aliases in app.php file.

那么,什么是解决此问题的正确方法.在laravel 5.11中安装软件包后发生了这种情况

So,what is the correct way to resolve this issue. Its happening after installing the packages in laravel 5.11

推荐答案

问题是,在您的config/app.php文件中,您可能会看到以下信息:

The problem is, in your config/app.php file, you'll probably see this:

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.

composer.json中,您将在脚本下看到:

In composer.json you'll see under scripts:

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

这意味着,每当您运行composer update时,它都会首先调用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.

两种解决方法:

将提供程序更改为类似于Laravel 4的字符串中的引号:

Change the provider to be a quote in strings like they were in Laravel 4:

"Artdarek\OAuth\OAuthServiceProvider",

(这就是为什么直到Laravel 5/ PHP 5.5 之前,没有人真正遇到过这个问题的原因

(that's why nobody really had this problem until Laravel 5 / PHP 5.5). Or...

真正的解决方案

只需运行composer install而不是composer update.无论如何,这就是您应该做的事情,因为您的队友所做的任何事情都与composer.lock中的库版本一起使用.因此,如果您运行install,则是a)安装已知的工作版本,b)绕过php artisan命令,直到安装完成.

Just run composer install instead of 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. 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.

如果您确实必须运行composer update,则将其与--no-scripts标志一起使用

If you really must run composer update, then use it with the --no-scripts flag

这篇关于Laravel 5.11 Composer更新错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆