In this article, the main focus is for resolving the error message which is triggered in a web application based on Laravel framework. So, as it is shown in the title of this article, there is a Laravel error message which is ‘NotFoundHttpException’ and it can be shown as follows :
The error ‘NotFoundHttpException’ is triggered when the web application is executed upon editing a role or in other words, it is trying to edit a record in a table named ‘role’. The URL address in the address bar of the web browser can also give a descriptive information on the process executed. It is in the following part : ‘/role/edit/2’.
So, the URL which is accessed is not known and it cannot be processed by the Laravel framework itself. In order to solve the problem, the main solution is to be able to let Laravel framework which is supporting the web application that the URL given is valid and it is needed to be prcossessed. Furthermore, the main part of process which is responsible for handling the URL request is also defined. It is defined normally in the route file where in Laravel 5.3 it is done by editing the route file located in ‘routes/web.php’. Below, there is an output display to describe the location of the file in a tree form.
Route::get('/role/edit/{id_role}','RoleController@edit')
The above line is a snippet code retrieved from the source code available in a route file configuration located in ‘routes/web.php’. It is translated as every request or URL containing the pattern of ‘/role/edit/{id_role}’ will be processed further in the method named ‘edit’ inside the controller file with the name of ‘RoleController.php’. In the context of the directory tree of the web application project in Laravel 5.3, the location of the route file configuration can be described as follows :
user@hostname:/var/www/html/laravel-project$ tree routes/ routes/ ├── api.php ├── console.php └── web.php 0 directories, 3 files user@hostname:/var/www/html/laravel-project$
After adding the line of code specified above in the file named web.php which is located in routes folder, re-execute the page for accessing the edit form page.
One thought on “Laravel Error Message NotFoundHttpException”