I have set mode in .env file as: APP_DEBUG = false;
Now when error is happen it shows empty page with header: "Error".
How to make separated page for that?
You create a template in the views/error folder with name after the error code you want it to handle see https://laravel.com/docs/5.4/errors#custom-http-error-pages
You can create Blade templates for specific HTTP error codes in resources/views/errors/xxx.blade.php. For instance you can make resources/views/errors/500.blade.php for Internal Server Errors or resources/views/errors/404.blade.php for instances where a page can not be found. More here: https://laravel.com/docs/5.4/errors#custom-http-error-pages
Related
I have a working Laravel project with loads of different routes.
I'm currently testing it and one of my tests was to check if a user were to use a delete or post route from the URL. I didn't know what the application would do honestly and it outputted the typical:
The GET method is not supported for this route. Supported methods: DELETE
which I have seen a million times. Is there a way to stop this error from coming up and instead output an error screen or simply redirect to a different view?
The error message:
The GET method is not supported for this route. Supported methods: DELETE.
should only appear when your Laravel site has APP_DEBUG set to true (in the .env file).
When APP_DEBUG is set to false as it should always be in on a live site, then the user will be shown a 404 error page instead.
You can easily test this by adding the following code to your routes file:
Route::delete('test', function() {
return 'You should never see this text when viewing url via a GET request';
});
May be u didn't noticed but ur form tag method attribute and route definition is different
When I got an error in laravel site then i have received this error page.I want to redirect to another page which I have created custom looks like a valid error page.
enter image description here
enter image description here
First in your .env file (in your project's root) set false for app_debug ->
APP_DEBUG=false
Then create a file named 500.blade.php that contains your custom html css in (resources\views\errors)
Done.
(for others errors like 404 , 503 , just change the name of file to that error code)
More information Here
I am successfully loading a page in a new window using target="_blank",but the problem is the new window is loading with an error NotFoundException, when i try to pass id from the current window to new window
{{$stud->name}}
Route::get('search/display/{$id}','studcontroller#searchstud');
.....
NotFoundException is occurred for the routes not declared.
Check if you have created a route in routes.php.
Also verify the method to be GET.
If you have cached your routes earlier, try refreshing the route cache by using the command php artisan route:cache.
NOTE: This route cache command will work only if you are not using any
closure route.
One more thing you can do to get proper link is, use Url::to() method supported by Laravel Illuminate.
You're not closing the href attribute value. So, add ":
{{$stud->name}}
Like #Alexey mentioned you where missing quotes, but you will also have to send the id parameter
{{$stud->name}}
We have a custom error page.
In production or staging you get the custom error page if you try to visit a non-existing page, e.g. /random_fhdjfhdjfhdj.html
I want to add a feature test to check the content of the custom error page but in development and test modes I get No route matches [GET] "/random_fhdjfhdjfhdj.html"
The error page template we use is in app/views/exceptions/error.html.haml
Adding config.consider_all_requests_local = false
in
environments/test.rb
fixed this.
fyi we already had
config.action_dispatch.show_exceptions = true
set
When I type an invalid url (non-existent controller), it displays the homepage rather than return a 404 Page Not Found page. Does anyone know the possible reason?
Thanks
Have checked if there is any plugins are registered in the bootstrap and if is it configured to catch the exceptions or set any ACL mechanisms.
Also check the error controller too. may be there is some forwarding methods implemented there.
Hi i've had the same problem and i now know how to fix it:
within the bootstrap have the following init
function _initModules()
{
$this->bootstrap('frontController') ;
$front = $this->getResource('frontController') ;
$front->addModuleDirectory(APPLICATION_PATH . "/modules");
$front->setParam("useDefaultControllerAlways", false);
}
Setting 'useDefault....' will use the default controller when a 404 occurs.
You should also make sure your error controller is setup correctly