Composer build failed on Laravel 5 (production only)

I have a very strange problem since yesterday. Running composer install on my production server causes this error ... Keep in mind that I am not getting any errors on my local server (Homestead VM).

 Nothing to install or update Writing lock file Generating autoload files Executing command (CWD): php artisan clear-compiled Executing command (CWD): php artisan optimize Generating optimized class loader Compiling common classes Script php artisan optimize handling the post-install-cmd event returned with an error [RuntimeException] Error Output: Exception trace: () at phar:///home/site/public_html/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:177 Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///home/site/public_html/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:91 Composer\EventDispatcher\EventDispatcher->dispatchScript() at phar:///home/site/public_html/composer.phar/src/Composer/Installer.php:342 Composer\Installer->run() at phar:///home/site/public_html/composer.phar/src/Composer/Command/InstallCommand.php:131 Composer\Command\InstallCommand->execute() at phar:///home/site/public_html/composer.phar/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257 Symfony\Component\Console\Command\Command->run() at phar:///home/site/public_html/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:874 Symfony\Component\Console\Application->doRunCommand() at phar:///home/site/public_html/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:195 Symfony\Component\Console\Application->doRun() at phar:///home/site/public_html/composer.phar/src/Composer/Console/Application.php:146 Composer\Console\Application->doRun() at phar:///home/site/public_html/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:126 Symfony\Component\Console\Application->run() at phar:///home/site/public_html/composer.phar/src/Composer/Console/Application.php:83 Composer\Console\Application->run() at phar:///home/site/public_html/composer.phar/bin/composer:43 require() at /home/site/public_html/composer.phar:25 install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [--ignore-platform-reqs] [packages1] ... [packagesN] 

So it seems that the error appears in post-install-cmd when php artisan optimize configured to run ... It is strange that when I run all post-install-cmd manually, I DO NOT get any errors.

So I tried:

  • composer selfupdate
  • Removing the composer and reinstalling it
  • Using composer.phar instead of global
  • Running composer dumpautoload
  • delete composer.lock file
  • delete the entire cache composer clearcache
  • composer update works, in production (frantically)

And still get the same error. Do you have ideas? I'm running out of keywords to find similar issues on the Internet.

Thank you so much

EDIT:

Also failed to mention that the site is working fine. There is no error viewing.

EDIT 2:

As suggested by @marcanuy, I tried to delete the vendor directory. So far, I have also cleared the compiled and composer cache. The composer re-downloaded / installed everything. And still get the same error.

EDIT 3:

So, I narrowed it down. I DIDN'T GET AN ERROR IF I SET APP_DEBUG to true ... When false, I get an error. Any idea why?

COMPLETION:

Thanks to Ben Johnson, who pointed me in the right direction ... I checked my raw PHP logs and yes, they are different from laravel logs (I must think about that). I saw there a strange memory error not related to the files in the error stack above:

 [02-Jun-2015 14:05:01 Europe/Paris] PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 64 bytes) in /vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php on line 169 

After the moment tady. I raised memory_limit and composer install worked without errors, and disconnected with APP_DEBUG.

Thank you all for your help.

+7
php laravel laravel-5 composer-php dev-to-production
source share
2 answers

Have you studied raw PHP logs?

It is imperative to note that Laravel logs do not contain all the same information as PHP raw error logs. When using Laravel, always check the raw PHP logs when an error occurs and the visible output and the Laravel log do not reveal the root cause.

It is equally important to note that Composer obeys the whims of any PHP file that it downloads and processes, which means that any type of error that may occur in a PHP file that is not completely associated with Composer can cause the Composer to fail, often Without explaning the reason. However, the main reason is almost always manifested in raw PHP logs.

Invalid empty method signature at the top of the stack trace. I suspect that if you check the raw PHP logs, you will find an unusual condition that fully explains the sudden termination of composer.phar .

Please check it below and let us know what you find.

+2
source share

The problem is with php artisan optimize and not with composor.phar , as you can see in the Optimization Framework for better performance , if APP_DEBUG is true, you need to use the --force command with the command. To resolve this error, you need to change the line composor.json in the "post-install-cmd" section from "php artisan optimize" to "php artisan optimize --force"

0
source share

All Articles