2

我的应用程序在本地运行良好,并且在 Digital Ocean 上运行。但是我在 Laravel Forge 上收到以下两个备用部署错误。

如果我运行:

composer update --no-dev
php artisan optimize

然后我在 Forge 上收到以下错误:

[RuntimeException]
The lock file does not contain require-dev information, run install with the --no-dev option or run update to install those packages.

如果我运行:

composer update
php artisan optimize

然后我在 Forge 上得到这个:

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:  Call to undefined method
Illuminate\Foundation\Application::getCachedCompilePath() in /home/forge/default/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClearCompiledCommand.php on line 28
PHP Stack trace:
PHP   1. {main}() /home/forge/default/artisan:0
PHP   2. Illuminate\Foundation\Console\Kernel->handle() /home/forge/default/artisan:36
PHP   3. Symfony\Component\Console\Application->run() /home/forge/default/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:94
PHP   4. Symfony\Component\Console\Application->doRun() /home/forge/default/vendor/symfony/console/Symfony/Component/Console/Application.php:126
PHP   5. Symfony\Component\Console\Application->doRunCommand() /home/forge/default/vendor/symfony/console/Symfony/Component/Console/Application.php:195
PHP   6. Illuminate\Console\Command->run() /home/forge/default/vendor/symfony/console/Symfony/Component/Console/Application.php:874
PHP   7. Symfony\Component\Console\Command\Command->run() /home/forge/default/vendor/laravel/framework/src/Illuminate/Console/Command.php:101
PHP   8. Illuminate\Console\Command->execute() /home/forge/default/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
PHP   9. Illuminate\Container\Container->call() /home/forge/default/vendor/laravel/framework/src/Illuminate/Console/Command.php:115
PHP  10. call_user_func_array:{/home/forge/default/storage/framework/compiled.php:925}() /home/forge/default/storage/framework/compiled.php:925
PHP  11. Illuminate\Foundation\Console\ClearCompiledCommand->fire() /home/forge/default/storage/framework/compiled.php:925

[Symfony\Component\Debug\Exception\FatalErrorException]                             
Call to undefined method Illuminate\Foundation\Application::getCachedCompilePath()
Script php artisan clear-compiled handling the post-install-cmd event returned with an error

[RuntimeException
Error Output: PHP Fatal error:  Call to undefined method Illuminate\Foundation\Application::getCachedCompilePath() in /home/forge/default/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClearCompiledCommand.php on line 28  
PHP Stack trace:                                                                                                                                                                                                                          
PHP   1. {main}() /home/forge/default/artisan:0                                                                                                                                                                                           
PHP   2. Illuminate\Foundation\Console\Kernel->handle() /home/forge/default/artisan:36                                                                                                                                                    
PHP   3. Symfony\Component\Console\Application->run() /home/forge/default/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:94                                                                                        
PHP   4. Symfony\Component\Console\Application->doRun() /home/forge/default/vendor/symfony/console/Symfony/Component/Console/Application.php:126                                                                                          
PHP   5. Symfony\Component\Console\Application->doRunCommand() /home/forge/default/vendor/symfony/console/Symfony/Component/Console/Application.php:195                                                                                   
PHP   6. Illuminate\Console\Command->run() /home/forge/default/vendor/symfony/console/Symfony/Component/Console/Application.php:874                                                                                                       
PHP   7. Symfony\Component\Console\Command\Command->run() /home/forge/default/vendor/laravel/framework/src/Illuminate/Console/Command.php:101                                                                                             
PHP   8. Illuminate\Console\Command->execute() /home/forge/default/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257                                                                                               
PHP   9. Illuminate\Container\Container->call() /home/forge/default/vendor/laravel/framework/src/Illuminate/Console/Command.php:115                                                                                                       
PHP  10. call_user_func_array:{/home/forge/default/storage/framework/compiled.php:925}() /home/forge/default/storage/framework/compiled.php:925                                                                                           
PHP  11. Illuminate\Foundation\Console\ClearCompiledCommand->fire() /home/forge/default/storage/framework/compiled.php:925

我究竟做错了什么?

4

1 回答 1

2

可能在这里做的最简单的事情就是这个。

  1. 在您的本地开发环境中,仔细检查您的 composer.json 文件中的“require”部分中应该在“require-dev”部分中的任何项目,并在需要时移动它们
  2. 删除本地 composer.lock 文件
  3. 运行作曲家安装composer update -vvv
  4. 在本地测试您的应用程序
  5. 当对一切都符合您的期望感到满意时,将您的 composer.lock 文件提交回您的版本控制系统并在 Forge 上重新部署应用程序

如果您在部署时继续遇到错误并且服务器上没有其他价值,我会销毁您的旧服务器实例,然后在 Forge 上创建一个新服务器。让它使用新的 composer.lock 文件运行构建,我相信它会让你解决这个问题。:-D

在另一个可能有帮助的注意事项上,通常在部署时我会优先composer install考虑composer update,因为我将根据 composer.lock 文件中记录的特定版本的依赖项测试功能。遵循这种方法意味着应用程序行为应该更可预测。在您或您的依赖项之一依赖始终是最新版本的库(例如 dev-master)时,您将面临不可预测的行为,因为代码可能会非常频繁地更改。

于 2015-04-29T12:49:26.260 回答