After extensive search on the web, I still can't figure this out. CWebLogRoute doesn't show SQL debug info, but CFileLogRoute does. Any ideas on how to get CWebLogRoute to work? Thanks!
Here is my config file:
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=myname',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'enableParamLogging'=>true,
'enableProfiling'=>true,
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning, trace, info',
),
array(
'class'=>'CWebLogRoute',
'levels'=>'error, warning, trace, info',
),
)
Does it show at least something? It's working fine on my local. Try to add profile into CWebLogRoute.levels.
BTW I prefer CProfileLogRoute for sql:
array(
'class'=>'CProfileLogRoute',
'enabled'=> YII_DEBUG,
),
This doesn't directly answer your question, but I've found the Yii debug toolbar to be a fantastic add-on on a job I've been doing recently. It will display not only the SQL statements you are running (the literal ones, not the parameterized versions), but also has a lot of other information that you actually do need fairly regularly ...
You can get it here: http://www.yiiframework.com/extension/yii-debug-toolbar/
what's the version of your yii framework?
and set the levels '' .
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
// 'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
array( // configuration for the toolbar
'class'=>'XWebDebugRouter',
'config'=>'alignRight, opaque, runInDebug, fixedPos, collapsed, yamlStyle',
// 'levels'=>'error, warning, trace, profile, info',
'allowedIPs'=>array('127.0.0.1','::1','192.168.10.195','192\.168\.1[0-5]\.[0-9]{3}'),
),
),
),
Related
I am trying to create a simple web application using yii. I have install WAMP 2.5 and yii 1.1.x. I have also created a skeleton application called yiitest. I have also created a database with mysql called yiitest which has a table called persons and has the following columns: pid, fname, lname, dob, zip. I am trying to build the basic functionality of the web app using gii. I can log into gii and navigate to Controller Generator Form Generator and Module Generator, but when I try to click on Crud Generator or Model Generator I get a CDbException error.
Here is my code:
protected/config/database.php
<?php
// This is the database connection configuration.
return array(
//'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
// uncomment the following lines to use a MySQL database
'connectionString' => 'mysql:host=localhost;dbname=yiitest',
'emulatePrepare' => true,
'username' => 'yiiUser',
'password' => 'p4ssw0rd',
'charset' => 'utf8',
);
protected/config/main.php
<?php
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Web Application',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
),
'modules'=>array(
// uncomment the following to enable the Gii tool
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'password',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to enable URLs in path-format
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
// database settings are configured in database.php
'db'=>require(dirname(__FILE__).'/database.php'),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'webmaster#example.com',
),
);
Any help on getting gii's Model Generator and Crud Generator working would be very helpful!
****Edit****
Here is a picture of the error I receive:
Could be you don'have a valid db connection
check in you dirname(__FILE__).'/database.php' if you have valid parameter
somethings like this
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=my_dbname',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'my_pwd',
'charset' => 'utf8',
),
I am a newbie to yii and I am installing extension auditTrail.
I have made all the required changes to my main.php config file but everytime it is showing the same error
'Alias "auditTrail.AuditTrailModule" is invalid. Make sure it points
to an existing PHP file and the file is readable.'
Please help me out. thankyou in advance.. my editted file is here:
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Web Application',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
'application.modules.auditTrail.models.AuditTrail',
),
'modules'=>array(
'auditTrail'=>array(),
// uncomment the following to enable the Gii tool
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>false,
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to enable URLs in path-format
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
),
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=assetdb',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'Preksha#12',
'charset' => 'utf8',
),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'webmaster#example.com',
),
);
here is the error ::
CException
Alias "auditTrail.AuditTrailModule" is invalid. Make sure it points to an existing PHP file and the file is readable.
I have used Codeigniter before and it has a feature that will echo the last database query - really useful for debugging.
eg...
$this->getSomeData->findAll();
Yii command to output this single query e.g SELECT * FROM TABLE...
Does Yii have a similar feature to simply show the very last query executed?
Try this in your config file. You can see the query and other details at the bottom of the page.
'db'=>array(
'enableProfiling'=>true,
'enableParamLogging' => true,
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
…
array(
'class'=>'CProfileLogRoute',
'levels'=>'profile',
'enabled'=>true,
),
),
),
'errorHandler' => array(
'class' => 'ErrorHandler',
'errorAction' => 'page/find',
),
http://shot.qip.ru/008pAk-4IA4wMhU6/
I have standard error handling with beautiful error page. But for develop environment I need standard stacktrace on it below.
Examlpe: http://shot.qip.ru/008pAk-4IA4wMhU7/
If I comment 'errorAction' I can see just standart stacktrace, in other case I cant display this stacktrace.
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class' => 'CWebLogRoute',
'categories' => 'application, exception.*',
'levels'=>'error, warning, trace, profile, info',
'showInFireBug' => true,
'enabled' => YII_DEBUG,
),
array(
'class'=>'ext.yii-debug-toolbar.YiiDebugToolbarRoute',
'ipFilters'=>array('127.0.0.1','192.168.0.100'),
),
array(
'class'=>'CProfileLogRoute',
'report'=>'summary',
// Shows the execution time of each labeled with a code block.
// The value of "report" can also be specified as a "callstack".
),
),
),
Error handler by default uses two types of views for
Production named as error.php;
Development named as named as exception.php;
Based on your routing and error handler code. I see you have defined a custom error action
You will have to place your custom Errors views in either of the following folders, in the format specified in the link below and use the standard error action.
themes/ThemeName/views/system: when a theme is active.
protected/views/system
See this Documentation for detailed explanation
Reference: http://www.yiiframework.com/doc/api/1.1/CErrorHandler
Try this extenstion http://www.yiiframework.com/extension/yii-debug-toolbar/
The Yii Debug Toolbar is a configurable set of panels that display various debug information about the current request/response and when clicked, display more details about the panel's content.
It is a ported to PHP famous Django Debug Toolbar.
i have enabled profiling to be displayed in yii as below shown.
'db'=>array(
'connectionString'=>'pgsql:host=localhost;port=5432;dbname=ijob_css',
'username'=>'postgres',
'password'=>'allion123',
'enableProfiling'=>true,
'schemaCachingDuration'=>604800
),
but still i am not getting anything displayed under the pages of website and its empty.
before it worked and recently i swiotched off by
'enableProfiling'=>false
why doesn't it work ? i must be missing something.
Adding this to main config resolved the issue. 'class'=>'CProfileLogRoute',
'components'=>array(
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
array(
'class'=>'CProfileLogRoute',
),