error.html.php with autoloaded configuration
I have a problem with the error page 500 of symfony (apps/%app-name%/config/error/error.html.php). I had to learn that symfony skip the standard way of page creation completely. I had to organize all the helpers myselve.
require_once dirname(__FILE__) . '/../../../../lib/vendor/symfony/lib/helper/HelperHelper.php';
use_helper('Tag', 'Asset', 'Url', 'I18N', 'Date', 'Partial');
But now I am missing the contents o开发者_Python百科f the configuration. How can I manually trigger the autoloader mechanism, so that I get the information from view.yml and so on?
I don't know if it's smart to depend on the whole Symfony stack when you're displaying an error.
IMHO the error pages need to be designed as light-weight as possible, 99% static HTML, with only some php code to display a friendly error message. Because, what if something is wrong with your Symfony stack, then you can't even present a decent error page to the user.
The 500 error page is also a "hard fail" page, it is the most generic error handler which is only shown if no action tried to catch the exception.
In the cases where you want to use the view and everything, I think it's better to catch the exceptions right there in the action, and present better error pages (return sfView::ERROR
) with information the user can act on.
精彩评论