Laravel 5错误页面

I'm having problems creating error pages for my L5 app. I created a controller called BaseController which has all my CSS/JS and every other controller I have extends from it. How does one create an error 404 page which also extends BaseController?

Simply creating a view in views/errors/404.blade.php does not work since no styles are loaded. I'm using Twigbridge which is really useful when working with views.

Am assuming when you say controller has CSS/JS it means that your setting up layout using controllers.

Please note that this works for routes that you clearly define in your routes file and their respective controllers extend the Base.

For Error Pages they are not handle by your controllers. The error handlers are responsible for rendering their views and won't extend any layout. Hence you need to complete define it in your error view.

This should get you off on the right foot. Just use your standard extends syntax to extend your "default" layout. Do a search for App::error, you will find the right spot.

App::error(function(Exception $exception, $code)
{
$params = array();
$request = Request::create('cms/noroute', 'GET', $params);
return Route::dispatch($request)->getContent();
});

There is no need to handle the errors within a controller or even the assets files. Imagine you have an error from laravel (missing a config file) so you will have the error before event the code could reach a controller. The same case goes for 404. If you do not have that route available, there is no need to let user reach a controller, this is handled by Exception Handler.

A good resource to learn more is Laravel documentation and this blog post