'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.
Related
I want to make my own module in zend framework2, I have tried this below code as per the doc. mentioned
return array(
'modules' => array(
'Application',
'Album',
'Photo',
'SanAuth',
'Newmodule', // <- here is my newly added module name
),
'module_listener_options' => array(
'config_glob_paths' => array(
'config/autoload/{,*.}{global,local}.php',
),
'module_paths' => array(
'./module',
'./vendor',
),
),
);
But when I add this only one line code! my all working module gives blank result even which are working fine started giving blank result!
How can I come out from this ?
What you did is enabling the Module. You should have created it first.
Take a look here.
And you can use ZFTool for module managing (it saves you from the dull process).
It's normal to see a blank screen. There is an Exception being thrown which is probably saying that your module doesn't exist or something like that. Make sure you set display_errors = On in your php.ini, so you can debug in an easier manner.
All you have done it tell Zend to start looking for a new module, but you have yet to create the module.
to create the module you need to add a folder with the same name under the ./module folder.
namespace ModuleName;
Class Module {
}
which is the minimum a module needs to load.
I was trying to add new error 404 page for my module. I have Application and my own Admin module. For Application I use default 404.phtml, for my new module I created admin404.phtml but I have no idea how to run it. There are a lot of options how to change layout for modules but I couldn`t find answer for my question.
Can anyone help me?
When a page could not be found or some other error happens inside of your web application,
a standard error page is displayed. The appearance of the error page is controlled by the
error templates. There are two error templates: error/404 which is used for "404 Page Not Found" error, and error/index which is displayed when an unhandled exception is thrown somewhere inside of the application.
The module.config.php file contains several parameters under the view_manager key, which you can use to configure the appearance of your error templates:
<?php
return array(
//...
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
//...
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => array(
//...
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index'=> __DIR__ . '/../view/error/index.phtml',
),
'template_path_stack' => array(
__DIR__ . '/../view',
),
),
);
The display_not_found_reason parameter controls whether to display the detailed
information about the "Page not Found" error.
The display_exceptions parameter defines whether to display information about
an unhandled exception and its stack trace.
The not_found_template defines the template name for the 404 error.
The exception_template specifies the template name for the unhandled exception error.
You typically set the display_not_found_reason and display_exceptions parameters
to false in production systems, because you don't want site visitors see the details
about errors in your site. However, you will still be able to retrieve the detailed
information from Apache's error.log file.
I am trying to change the styling of the gridview, tableview, & detailview. I found something saying that I should change the config/main.php file to this:
...
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
'bootstrap'=>array(
'class'=>'bootstrap.components.Bootstrap',
),
'widgetFactory'=>array(
'widgets'=>array(
'CGridView'=>array(
'cssFile' => Yii::app()->request->baseUrl.'/css/table_and_grid.css',
),
),
),
...
I have removed the assets folder that is generated by the app, but that didn't help. When I load the view, I can see that the css sheet is being loaded into the header of the page, but none of the styling is working. Why? How do I fix?
I haven't seen anything about changing the style of CGridView in main config file(main.php), But you can customize CGridView styles with bellow parameters:
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'SOME ID',
'dataProvider'=>$YOUR_DATA_PROVIDET,
'cssFile'=>'...',
'baseScriptUrl'=>'...',
'filterCssClass'=>'...',
'itemsCssClass'=>'...',
'pagerCssClass'=>'...',
'rowCssClass'=>'...',
'summaryCssClass'=>'...',
));
You can change ... with your own.
for more information you can check CGridView's Official document on the following link:
CGridView
I've created a module, a basic copy of the the albums example given in the ZF2 documentation, however, with the new module, I am not able to access it at all - I'm always given a 404 error. I'm building this on the ZF2 skeleton.
I've got three modules loaded: Application, Frontend and Security.
Both Frontend and Security are duplicates of each other, however, I have thoroughly checked and there is no reference to old code (as I literally copied the module folder and renamed/rewrote references).
The module is also loaded in application.config.php.
Any ideas on what I'm missing?
Module Config:
return array(
'controllers' => array(
'invokables' => array(
'Security\Controller\Security' => 'Security\Controller\SecurityController',
),
),
'router' => array(
'routes' => array(
'security' => array(
'type' => 'segment',
'options' => array(
'route' => '/security[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Security\Controller\Security',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'security' => __DIR__ . '/../view',
),
),
);
I had the same problem while following the skeleton application tutorial (Getting started: A skeleton application). Whenever I would go to the album url in the browser (ZendSkeletonApplication/public/album in my case), I would get a 404 error page but no details on why I got the 404. It wasn't clear to me how I would be able determine why I was getting the 404 when I had double checked everything and was pretty sure I copied and configured the Album module properly. It turned out that I was missing a slash in my route (module.config.php). For example I had 'route' => 'album[/:action][/:id]' instead of 'route' => '/album[/:action][/:id]'.
I was only able to figure it out by intentionally causing errors by misspelling things like making the 'Album\Controller\Albums' instead of 'Album\Controller\Album'in the invokables value, this would cause a stack trace to display which then showed the ZF2 classes that where called on the request. I would continue to misspell, test, and then correct each part of the module.config.php until I was given a clue to what part of the configuration was causing the error.
I'm pretty sure this was not the best way to debug an application's configuration.
There is few things that need to be make sure is:-
You have to add your module in
application.config.php (which you are saying you done it.)
Security\Controller\Security has to be same in default too (which you already has)
One more thing is Your folder structure....
-
Just to doulbe check you have a /MODULE/src/MODULE/Controller/CONTROLLER_FILE_NAME.php
I hope that helps..
I know it is an old post. However another thing to make sure you have in the modules top directory (same directory as the Module.php file) is the "autoload_classmap.php"
file with "<?php return array();?>" inside of it.
A simple tip to know whether your rule has already added correctly to the routes or not, you may check the routes value in the config file inside any working module, as following:
$config = $this->serviceLocator->get('config');
var_dump($config);
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}'),
),
),
),