在必须通过FTP手动部署到缺乏SSH访问的客户端服务器之前,我运行了composer install --no-dev
。当我这样做时,我收到了以下错误:
PHP Fatal error: Class 'WayGeneratorsGeneratorsServiceProvider' not found in C:wwwtest.devlaravelvendorlaravelframeworksrcIlluminateFoundationProviderRepository.php on line 158
PHP Stack trace:
PHP 1. {main}() C:wwwtest.devlaravelartisan:0
PHP 2. require_once() C:wwwtest.devlaravelartisan:30
PHP 3. require() C:wwwtest.devlaravelbootstrapstart.php:60
PHP 4. IlluminateFoundationProviderRepository->load() C:wwwtest.devlaravelvendorlaravelframeworksrcIlluminateFoundationstart.php:210
PHP 5. IlluminateFoundationProviderRepository->compileManifest() C:wwwtest.devlaravelvendorlaravelframeworksrcIlluminateFoundationProviderRepository.php:58
PHP 6. IlluminateFoundationProviderRepository->createProvider() C:wwwtest.devlaravelvendorlaravelframeworksrcIlluminateFoundationProviderRepository.php:122
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Class 'Way\Generators\GeneratorsServiceProvider' not found","file":"C:\Ampps\www\test.dev\laravel\vendor\laravel\framework\src\Illuminate\Foundation\ProviderRe
pository.php","line":158}}Script php artisan clear-compiled handling the pre-update-cmd event returned with an error
[RuntimeException]
Error Output: PHP Fatal error: Class 'WayGeneratorsGeneratorsServiceProvider' not found in C:wwwtest.devlaravelvendorlaravelframeworksrcIlluminateFoundationProviderRepository.php on line 158
PHP Stack trace:
PHP 1. {main}() C:wwwtest.devlaravelartisan:0
PHP 2. require_once() C:wwwtest.devlaravelartisan:30
PHP 3. require() C:wwwtest.devlaravelbootstrapstart.php:60
PHP 4. IlluminateFoundationProviderRepository->load() C:wwwtest.devlaravelvendorlaravelframeworksrcIlluminateFoundationstart.php:210
PHP 5. IlluminateFoundationProviderRepository->compileManifest() C:wwwtest.devlaravelvendorlaravelframeworksrcIlluminateFoundationProviderRepository.php:58
PHP 6. IlluminateFoundationProviderRepository->createProvider() C:wwwtest.devlaravelvendorlaravelframeworksrcIlluminateFoundationProviderRepository.php:122
每个app.php
文件都有'WayGeneratorsGeneratorsServiceProvider'
行。
在运行该composer命令之前,它工作得很好。为什么会发生这种情况,怎样才能解决?
4.1 Laravel。
在您的composer.json
文件中,您仅将way/generators
作为开发机器依赖项。如果在每个app.php
文件中都有服务提供者'WayGeneratorsGeneratorsServiceProvider'
,那么这意味着way/generators
既是开发机器又是部署机器依赖项。通过执行composer install --no-dev
,您说的是仅依赖于开发机器的软件包不应该放在vendor
目录中,这意味着软件包way/generators
没有安装在vendor
目录中。这就是为什么你会得到错误。
由于way/generators
只是一个开发依赖,您应该从app/config.php
中删除'WayGeneratorsGeneratorsServiceProvider'
,这样部署机器就不会寻找它。
同样,如果你在开发机器上工作并执行composer install --no-dev
, way/generators
包不会安装在vendor
目录中,你会得到上面的错误。因此,您必须将开发机器环境设置为非local
,以测试它是否在部署机器中工作。