PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, March 9, 2022

[FIXED] Set max_execution_time for specific controller in symfony2

 March 09, 2022     php, symfony     No comments   

Issue

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!


Solution

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
        // ..
    }
}


Answered By - Matteo
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing