phpquickprofiler Particletree.com Php Quick Profiler Wrapper

  1. Requirements
  2. Usage
  3. Resources

Particletree.com Php Quick Profiler Wrapper

Its a Web Log Router that will help you profile your application, its database profiling feature allows you to quickly find duplicated queries, see which queries are taking too long, the memory tab allows you to find memory leaks, and it also looks beautiful!

Requirements

Developed using Yii Framework 1.1.8 but it may work with other versions.

Usage

  • Download and extract the contents of the zip to your extensions folder
  • Configure the LogRoute in your application configuration
'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(
				array(
					'class'=>'CFileLogRoute',
					'levels'=>'error, warning',
				),
				array(
					'class' => 'application.extensions.pqp.PQPLogRoute',
					'categories' => 'application.*, exception.*',
				),
			),
		), 

Note: if you plan to use phpunit and for some reason you are using a config file that includes PQP you'll get errors about assets folder, to solve this you can set up you log route in the following way as suggested by thefsb

'log'=>array(
			'class'=>'CLogRouter',
			'routes' => array_merge(
		array(
			array(
				'class'=>'CFileLogRoute',
				'levels'=>'error, warning, info',
			),
		),
		array(php_sapi_name() !== 'cli'
			? array(
				'class' => 'application.extensions.pqp.PQPLogRoute',
				'categories' => 'application.*, exception.*, system.*',
				'levels'=>'error, warning, info',
			)
			: array('class'=>'CWebLogRoute', 'enabled'=>false)
		)
	),
		), 
  • Enable Database Profiling and param loggin:
'db'=>array(
			'connectionString' => '...',
			'enableProfiling' => true,
			'enableParamLogging' => true,
		),
  • Log as you normaly would with Yii using Yii::trace, Yii::log, Yii::beginProfile and Yii::endProfile, use PQPLogRoute::logMemory to log memory, you can use it to log objects to know its memory consumption, if you pass a string it will tell you know much memory has been used to that point.
/**
	 * Logs a memory message.
	 * @param mixed $obj any type of variable to profile memory
	 * @param string $msg message to be logged
	 * @param string  $category category of the message (e.g. 'system.web'). It is case-insensitive.
	 */
	public static function logMemory($obj, $msg = '', $category='application'){
PQPLogRoute::logMemory("memory used after action call");
try {
	Yii::beginProfile('Execution time');
	Yii::log('Begin logging data');
	PQPLogRoute::logMemory($this, "the site controller");
	$arr = array('Name' => 'Ryan', 'Last' => 'Campbell');
	Yii::log(CVarDumper::dumpAsString($arr));
	PQPLogRoute::logMemory($arr, "Normal array");
	$users = User::model()->findAll();
	PQPLogRoute::logMemory($users, "Users array");
	Yii::endProfile('Execution time');
	throw new Exception('Unable to write to log!');
}
catch(Exception $e) {
	Yii::log($e, CLogger::LEVEL_ERROR);
}
PQPLogRoute::logMemory("memory used before render");

Resources

  • Project page
  • Demo: in the downloads
  • Forum Post your questions there, avoid posting questions in the extension page.
  • Screenshots : Console Speed Database Memory Files
29 0
36 followers
2 106 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Logging
Developed by: Asgaroth
Created on: Nov 21, 2011
Last updated: 12 years ago

Downloads

show all

Related Extensions