Laravel 5.2 artisan optimize - php_strip_whitespace failed to open stream: No child processes

*爱你&永不变心* 提交于 2019-12-23 07:48:50

问题


Since upgrading to Laravel 5.2 from 5.1, when running artisan optimize on CircleCI, running PHP 5.6.14, I am getting

[ErrorException]                                                                                 
php_strip_whitespace(/var/laravel/project/root): failed to open stream: No child processes

Where /var/laravel/project/root is the directory where composer.json and vendor reside.

The command runs fine on my dev box running PHP 5.6.11-1ubuntu3.1. I followed the official 5.1 to 5.2 upgrade guide.

Exception trace:
() at /var/laravel/project/root/vendor/classpreloader/classpreloader/src/ClassPreloader.php:124
Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() at n/a:n/a
php_strip_whitespace() at /var/laravel/project/root/vendor/classpreloader/classpreloader/src/ClassPreloader.php:124
ClassPreloader\ClassPreloader->getCode() at /var/laravel/project/root/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php:83
Illuminate\Foundation\Console\OptimizeCommand->compileClasses() at /var/laravel/project/root/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php:64
Illuminate\Foundation\Console\OptimizeCommand->fire() at n/a:n/a
call_user_func_array() at /var/laravel/project/root/bootstrap/cache/compiled.php:1217
Illuminate\Container\Container->call() at /var/laravel/project/root/vendor/laravel/framework/src/Illuminate/Console/Command.php:169
Illuminate\Console\Command->execute() at /var/laravel/project/root/vendor/symfony/console/Command/Command.php:256
Symfony\Component\Console\Command\Command->run() at /var/laravel/project/root/vendor/laravel/framework/src/Illuminate/Console/Command.php:155
Illuminate\Console\Command->run() at /var/laravel/project/root/vendor/symfony/console/Application.php:787
Symfony\Component\Console\Application->doRunCommand() at /var/laravel/project/root/vendor/symfony/console/Application.php:186
Symfony\Component\Console\Application->doRun() at /var/laravel/project/root/vendor/symfony/console/Application.php:117
Symfony\Component\Console\Application->run() at /var/laravel/project/root/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107
Illuminate\Foundation\Console\Kernel->handle() at /var/laravel/project/root/artisan:36

Any ideas on how I can resolve this please?


回答1:


I found the answer on https://laracasts.com/discuss/channels/laravel/laravel-optimize-error where johnwheal mentions that config/compile.php is wrong.

It turns out that the files array in config/compile.php was emptied in a commit in April 2015 but I can't see the change mentioned in the Upgrade Guide. It has since been added to the Upgrade Guide.

To fix the problem either:

  • Empty the files array in config/compile.php

or

  • Remove BusServiceProvider.php and ConfigServiceProvider.php from the files array in config/compile.php .



回答2:


The reason for this error is the BusServiceProvider and ConfigServiceProvider have been removed, as part of the 5.1 to 5.2 transition. Although the answer provided to remove all compiled classes will fix the problem, the only two you need to remove is BusServiceProvider and ConfigServiceProvider from config/compile.php.

'files' => [ realpath(__DIR__.'/../app/Providers/AppServiceProvider.php'), realpath(__DIR__.'/../app/Providers/BusServiceProvider.php'), // This one realpath(__DIR__.'/../app/Providers/ConfigServiceProvider.php'), // And this one realpath(__DIR__.'/../app/Providers/EventServiceProvider.php'), realpath(__DIR__.'/../app/Providers/RouteServiceProvider.php'), ],



来源:https://stackoverflow.com/questions/34681541/laravel-5-2-artisan-optimize-php-strip-whitespace-failed-to-open-stream-no-ch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!