Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Enable profiler for admins only
  • How can I enable the PHP Profiler for admins? I tried putting some logic to the config file, something like 'profiling' => ( Auth::member(100) ); I also tried some code in the core files but I'm not a big fan of doing that. Any ideas?
  • The config is loaded very early in the bootstrap of the framework, so I guess Auth doesn't work. You can put this in the before() of your base controller, or create a helper class that you 'always_load' and put it in the _init() method of that class:
    if ( \Auth::check() )
    {
        \Fuel::$profiling = \Auth::member(100);
        \Profiler::init();
        \Profiler::mark(__METHOD__.' Start');
    }
    

    I personally don't like to have the profiler on all the time, so I use a GET variable. I have this in my config file:
    'profiling' => (Fuel::$env == 'development' and isset($_GET['profile']),
    
    which allows me to enable profiling by adding "?profile" to any URL when I'm in development.
  • Thanks, that works great!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion