-
John_Betong Super Moderator
     
-
Posts: 588
Threads: 52
Joined: Oct 2014
Reputation:
4
04-29-2015, 07:22 PM
(This post was last modified: 04-29-2015, 07:27 PM by John_Betong.
Edit Reason: spelling: not my fortay
)
Try adding the following in your own ./config/config_personal.php
PHP Code: <?php # config_personal.php
defined ?: define('LOCALHOST, 'localhost'=== $_SERVER['SERVER_NAME']);
if( LOCALHOST): define('GOOGLE_ON', FALSE); $_SESSION['jjj'] = array ( 'angular' => FALSE, 'error_reporting' => -1, #-1==LOCAL 'display_errors' => 1, # 1==LOCAL 'threshold' => 1, # 1..4 agressive 'compress_result' => FALSE, # 'profiler' => TRUE, # DOES NOT ACCEPT 0 AS FALSE ????? 'MD5' => 1, # 1 == show cached filename 'cache_minutes' => 0, # minutes 'cache_path' => CACHEPATH,# define('CACHEPATH', APPPATH .'cache/current/'); ); else: # Must be ONLINE define('GOOGLE_ON', FALSE); $_SESSION['jjj'] = array ( 'angular' => FALSE, 'error_reporting' => -1, 'display_errors' => FALSE, # FALSE ONLINE 'threshold' => 1, # 1 ONLINE - 1..4 agressive 'compress_result' => FALSE, # Bl@@dy DISQUS DOES NOT WORK if COMPRESSED 'profiler' => FALSE, # DOES NOT ACCEPT 0 AS FALSE ????? 'cache_minutes' => 0, # 1,440 = minutes per day 'cache_path' => CACHEPATH, # define('CACHEPATH', APPPATH .'cache/current/'); ); endif; ini_set('error_log', APPPATH .'php_error.php'); error_reporting( $_SESSION['jjj']['error_reporting'] ); ini_set('display_errors', $_SESSION['jjj']['display_errors'] );
and I also have a common MY_Library:
PHP Code: //==================================================
class MY_Library extends CI_Controller {
function j_view(& $data=array(), $getLatestAndThumbs=TRUE) { $this->output->enable_profiler( $_SESSION['jjj']['profiler'] ); // lots of other stuff
$this->load->view( $data['page_new'], $data, FALSE); # FALSE == ON SCREEN display }//endfunc
}/// endclass
This has worked for many old CI_VERSIONS without any problems.
-
PaulD Posting Freak
    
-
Posts: 1,061
Threads: 42
Joined: Mar 2015
Reputation:
73
(04-29-2015, 03:32 PM)ivantcholakov Wrote: If it is introduced, maybe this global option should be not enforced in the same way for AJAX requests that output in non-HTML formats. For example, if an AJAX request returns in JSON format, the additional output from the profiler will damage the result, the client will be not able to parse it.
Yes that is true, and a good point. In fact also true of normal AJAX requests too. And how would that be identified? From the header? That is probelmatic in itself I suspect.
From above
(04-29-2015, 06:07 PM)InsiteFX Wrote: This is how I do it with a profiler.php config file.
That is a really neat and clever suggestion. Then I can include or not include in controllers I use for ajax and other things where the profiler would not be required. I really like this approach. Simple, clear and effective. Thank you. At the moment I just include the profiler line in all my controllers but commented out and I uncomment when I need it. However going to all the individual controllers (especially in a complicated routing site) is a pain. Your approach will work superbly for me, thank you again.
Anyway, given all the points raised in earlier posts, perhaps enabling the profiler globally just has too many complications and inherent problems. I would still like to have it as a config or autoload global variable, but I can see now why maybe the CI developers would prefer not to do it.
The debugging help provided by the profiler is just so useful and so powerful that I thought it would be handy to turn it on for all pages when needed and off for all pages when a site goes live globally.
Thanks for all the replies though.
Best wishes,
Paul
-
InsiteFX Super Moderator
     
-
Posts: 6,742
Threads: 346
Joined: Oct 2014
Reputation:
247
05-01-2015, 01:12 AM
(This post was last modified: 05-01-2015, 01:19 AM by InsiteFX.)
profiler.php - Create this file in application/config
PHP Code: <?php defined('BASEPATH') OR exit('No direct script access allowed');
/* | ------------------------------------------------------------------------- | Profiler Sections | ------------------------------------------------------------------------- | This file lets you determine whether or not various sections of Profiler | data are displayed when the Profiler is enabled. | Please see the user guide for info: | | http://codeigniter.com/user_guide/general/profiling.html | */
$config['benchmarks'] = TRUE; // Elapsed time of Benchmark points and total execution time. $config['config'] = TRUE; // CodeIgniter Config variables. $config['controller_info'] = TRUE; // The Controller class and method requested. $config['get'] = TRUE; // Any GET data passed in the request. $config['http_headers'] = TRUE; // The HTTP headers for the current request. $config['memory_usage'] = TRUE; // Amount of memory consumed by the current request, in bytes. $config['post'] = TRUE; // Any POST data passed in the request. $config['queries'] = TRUE; // Listing of all database queries executed, including execution time. $config['uri_string'] = TRUE; // The URI of the current request. $config['session_data'] = TRUE; // Data stored in the current session. $config['query_toggle_count'] = 25; // The number of queries after which the query block will default to hidden.
/** * ------------------------------------------------------------------------ * Filename: profiler.php * Location: ./application/config/profiler.php * ------------------------------------------------------------------------ */
config.php - Add to the top of file
PHP Code: /* |-------------------------------------------------------------------------- | Use CodeIgniter Profiler |-------------------------------------------------------------------------- | / TRUE / FALSE | */ $config['profiler'] = FALSE;
MY_Controller
PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/** * ------------------------------------------------------------------------ * Editor : phpDesigner 8.1.2 * Date : 10/17/2013 * Time : 9:07:10 AM * Authors : Raymond L King Sr. * ------------------------------------------------------------------------ * * Class MY_Controller * * ------------------------------------------------------------------------ * To change this template use File | Settings | File Templates. * ------------------------------------------------------------------------ */
class Base_Controller extends CI_Controller {
/** * -------------------------------------------------------------------- * Class variables - public, private, protected and static. * -------------------------------------------------------------------- */
// --------------------------------------------------------------------
/** * __construct * * Class Constructor PHP 5+ * * @access public * @return void */ public function __construct() { parent::__construct();
// check to see if we want to use the CI profiler. $this->output->enable_profiler($this->config->item('profiler'));
} }
Quick and simple
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
-
RWCH Junior Member
 
-
Posts: 42
Threads: 5
Joined: Feb 2015
Reputation:
3
05-01-2015, 06:08 AM
(This post was last modified: 05-01-2015, 06:09 AM by RWCH.)
I have used a similar approach as InsiteFX. It's simple. Anybody can use it this way, so no need for 'extra switches'.
Configuration is simply done in your configuration file ... also for enabling/disabling a profiler.
|