Framework: PHP Artisan Optimize - Timed out?

Created on 23 Apr 2013  ·  23Comments  ·  Source: laravel/framework

Hi Guys.
I am trying to install a package via composer, but everytime it get to the 'artisan optimize' part it fails with the following error:

c:\wamp\www\adam\L4>composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Generating autoload files

Generating optimized class loader...

[Symfony\Component\Process\Exception\RuntimeException]
The process timed-out.

optimize

Script php artisan optimize handling the post-update-cmd event returned with an
error:

[Symfony\Component\Process\Exception\RuntimeException]
The process timed-out.

optimize

Most helpful comment

If you have done what @jeliasson suggested and still it doesn't work, check you're not running a debugger.

I'm use PhpStorm and if the Xdebug debug is running php artisan optimize will run out.

All 23 comments

This might sound like a silly question but how long does it take to timeout?

Hey,

Try again, by adding " --verbose (-v) Increase verbosity of
messages." to the composer command and let us know the results.

On Tue, Apr 23, 2013 at 9:54 AM, Will Meldon [email protected]:

This might sound like a silly question but how long does it take to
timeout?


Reply to this email directly or view it on GitHubhttps://github.com/laravel/framework/issues/1050#issuecomment-16856043
.

when i run 'php artisan optimize'
about 90 - 100 sec's at a guess.

I previously had this issue (https://github.com/laravel/framework/issues/922).
I then removed the bootstrap/compiled.php file, and then tried to re-run the optimize command and the composer update command.
Both got this far and timed out.

OK i tried the --verbose and got this:

c:\wamp\www\adam\L4>php artisan optimize --verbose
Generating optimized class loader...

[Symfony\Component\Process\Exception\RuntimeException]
The process timed-out.

Exception trace:
() at C:\wamp\www\adam\L4\vendor\symfony\process\Symfony\Component\Process\Proc
ess.php:1063
Symfony\Component\Process\Process->checkTimeout() at C:\wamp\www\adam\L4\vendor
\symfony\process\Symfony\Component\Process\Process.php:381
Symfony\Component\Process\Process->wait() at C:\wamp\www\adam\L4\vendor\symfony
\process\Symfony\Component\Process\Process.php:207
Symfony\Component\Process\Process->run() at C:\wamp\www\adam\L4\vendor\laravel\
framework\src\Illuminate\Foundation\Composer.php:47
Illuminate\Foundation\Composer->dumpAutoloads() at C:\wamp\www\adam\L4\vendor\l
aravel\framework\src\Illuminate\Foundation\Composer.php:57
Illuminate\Foundation\Composer->dumpOptimized() at C:\wamp\www\adam\L4\vendor\l
aravel\framework\src\Illuminate\Foundation\Console\OptimizeCommand.php:55
Illuminate\Foundation\Console\OptimizeCommand->fire() at C:\wamp\www\adam\L4\ve
ndor\laravel\framework\src\Illuminate\Console\Command.php:108
Illuminate\Console\Command->execute() at C:\wamp\www\adam\L4\vendor\symfony\con
sole\Symfony\Component\Console\Command\Command.php:242
Symfony\Component\Console\Command\Command->run() at C:\wamp\www\adam\L4\vendor\
laravel\framework\src\Illuminate\Console\Command.php:96
Illuminate\Console\Command->run() at C:\wamp\www\adam\L4\vendor\symfony\console
\Symfony\Component\Console\Application.php:940
Symfony\Component\Console\Application->doRunCommand() at C:\wamp\www\adam\L4\ve
ndor\symfony\console\Symfony\Component\Console\Application.php:204
Symfony\Component\Console\Application->doRun() at C:\wamp\www\adam\L4\vendor\sy
mfony\console\Symfony\Component\Console\Application.php:117
Symfony\Component\Console\Application->run() at C:\wamp\www\adam\L4\artisan:59

optimize

c:\wamp\www\adam\L4>

OK so i deleted the entire Symphony folder from the vendors directory.
Then i ran 'composer update'.
This appears to have fixed my issues :)
Adam.

I deleted the Symphony folder, ran "composer update" but am still getting the same error:

$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Generating autoload files
Generating optimized class loader...

[Symfony\Component\Process\Exception\RuntimeException]
The process timed-out.

optimize

I'm getting the same problem running in a development VM. The default timeout for Symfony's Process is 60 seconds. I fixed the problem in my case by modifying Composer.php. The fix was to add a "setTimeout(null)" to all new process instances when they get created by the getProcess() function.

e.g.

protected function getProcess()
{
  $process = new Process('', $this->workingPath);
  $process->setTimeout(null);
  return $process;
}

Exception trace:
() at /vagrant-dev/development/wwwroot/vendor/symfony/process/Symfony/Component/Process/Process.php:489
Symfony\Component\Process\Process->signal() at /vagrant-dev/development/wwwroot/vendor/symfony/process/Symfony/Component/Process/Process.php:769
Symfony\Component\Process\Process->stop() at /vagrant-dev/development/wwwroot/vendor/symfony/process/Symfony/Component/Process/Process.php:1069
Symfony\Component\Process\Process->checkTimeout() at /vagrant-dev/development/wwwroot/vendor/symfony/process/Symfony/Component/Process/Process.php:381
Symfony\Component\Process\Process->wait() at /vagrant-dev/development/wwwroot/vendor/symfony/process/Symfony/Component/Process/Process.php:207
Symfony\Component\Process\Process->run() at /vagrant-dev/development/wwwroot/vendor/laravel/framework/src/Illuminate/Foundation/Composer.php:47
Illuminate\Foundation\Composer->dumpAutoloads() at /vagrant-dev/development/wwwroot/vendor/laravel/framework/src/Illuminate/Foundation/Composer.php:57
Illuminate\Foundation\Composer->dumpOptimized() at /vagrant-dev/development/wwwroot/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php:55
Illuminate\Foundation\Console\OptimizeCommand->fire() at /vagrant-dev/development/wwwroot/vendor/laravel/framework/src/Illuminate/Console/Command.php:108
Illuminate\Console\Command->execute() at /vagrant-dev/development/wwwroot/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:244
Symfony\Component\Console\Command\Command->run() at /vagrant-dev/development/wwwroot/vendor/laravel/framework/src/Illuminate/Console/Command.php:96
Illuminate\Console\Command->run() at /vagrant-dev/development/wwwroot/vendor/symfony/console/Symfony/Component/Console/Application.php:892
Symfony\Component\Console\Application->doRunCommand() at /vagrant-dev/development/wwwroot/vendor/symfony/console/Symfony/Component/Console/Application.php:184
Symfony\Component\Console\Application->doRun() at /vagrant-dev/development/wwwroot/vendor/symfony/console/Symfony/Component/Console/Application.php:121
Symfony\Component\Console\Application->run() at /vagrant-dev/development/wwwroot/artisan:59

The issue is not with Laravel but with Symfony. Removing the whole Symfony folder is a bit rigorous. The issue has been reported a time ago with the Symfony devs. The commit in Symfony that fixed this can be found here: https://github.com/symfony/symfony/commit/50109ebcc20ae410d4602460dc933b1e067a959f.

To circumvent this time-out with Composer and Symfony with Laravel go to file /vendor/symfony/process/Symfony/Component/Process/Process.php, and set the timeout variable within the public function setTimeout() to zero => $timeout = 0; (that solved it 4 me, other solutions mentioned here did not).

Thanks @jayform your solution worked for me! :)

@jayform also worked for me, thanks!

Hello,
i have set $timeout = 0, but after some time i am getting the error:
Generating optimized class loader

[Symfony\Component\Process\Exception\ProcessTimedOutException]
The process "php artisan optimize" exceeded the timeout of 300 seconds.

Any sollution with this??
Thank you

i have this problem too.
but run php artisan optimize by manual ,no error output .
is it normal?

I know that this thread is old, and hopefully you've guys already solved it, but people arriving in this thread may be intrested in trying to adjust the "process-timeout" value in the Composer.json-file.

"config" : {
    "process-timeout": 0
  }

@jeliasson worked for me thanks! :+1: :smile:

had the same problem. Cost me two days to figure out.

Mine is because the APCu extension. Change apc.enable_cli to 0 then it worked.

I am using php 5.5.28 and windows 10, however in windows 7 is fine with the same configuration. So check your php.ini configuration.

Get a faster server, or increase the timeout.

@jeliasson thanks you really saved my ass.

If you have done what @jeliasson suggested and still it doesn't work, check you're not running a debugger.

I'm use PhpStorm and if the Xdebug debug is running php artisan optimize will run out.

@troccoli your solution worked for me. thanks

@troccoli worked for me, thanks~

had the same problem. Cost me two days to figure out.

Mine is because the APCu extension. Change apc.enable_cli to 0 then it worked.

I am using php 5.5.28 and windows 10, however in windows 7 is fine with the same configuration. So check your php.ini configuration.

Thanks! Following your opinion,I had solved my problem.

If you have done what @jeliasson suggested and still it doesn't work, check you're not running a debugger.

I'm use PhpStorm and if the Xdebug debug is running php artisan optimize will run out.

Absolutely right @troccoli!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lzp819739483 picture lzp819739483  ·  3Comments

SachinAgarwal1337 picture SachinAgarwal1337  ·  3Comments

CupOfTea696 picture CupOfTea696  ·  3Comments

RomainSauvaire picture RomainSauvaire  ·  3Comments

iivanov2 picture iivanov2  ·  3Comments