Using ini_set()
, I can expand the maximum execution time of a script. In Symfony2, I can add ini_set
to web/app.php
and web/app_dev.php
to apply the increased execution time to all controllers.
But in this case, I only want to expand the maximum execution time for one specific controller action in Symfony2. I'd rather not give other actions the possibility to run for a longer time than necessary.
I tried adding the ini_set
at the top of the action function in the controller, but that doesn't seem to work. Any solutions? Thanks!
Using PHP max_execution_time directive By default, the maximum execution time for PHP scripts is set to 30 seconds. If a script runs for longer than 30 seconds, PHP stops the script and reports an error.
max_execution_time int. This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. This helps prevent poorly written scripts from tying up the server. The default setting is 30 . When running PHP from the command line the default setting is 0 .
The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php. ini . When called, set_time_limit() restarts the timeout counter from zero.
You can disable the PHP timeout limit with the set_time_limit
function. More info here
as Example:
class TaskController extends Controller
{
public function longTaskAction()
{
set_time_limit(0); // 0 = no limits
// ..
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With