The mistake with code 404 may happen when something couldn’t be found. All the time, it happens when Laravel can’t find the mentioned course or the predetermined course isn’t enrolled. Likewise you can see it when a code tosses 404 Not Found in Laravel.
In this article we will explain how to troubleshoot Not Found in Laravel. You will figure out how to really look at enlisted courses, how to clear reserve and how to install and utilize the laravel/telescope bundle to investigate Laravel demands.
Fixing 404 Not Found in Laravel
The laravel/telescope bundle gives the best and most straightforward method for debugging demands in the Laravel structure. You can see all demands, their Update Database Records in Laravel Eloquent, headers, and the handling system. The bundle can show what middleware and regulator were utilized to deal with each solicitation.
Next I will show how to install and design Telescope. I expect that you have installed the Laravel system. On the off chance that you get this blunder, may you need to make Programming interface. You can peruse in more insight concerning in the article How to Make REST Programming interface in Laravel.
1. Install Telescope
To start with, install the laravel/telescope bundle for your undertaking using Writer:
- writer require – – dev laravel/telescope
Then, run distribute movements and design using the order beneath:
- php craftsman telescope:install
Subsequent to running telescope: install order, make data set tables using order:
- php craftsman relocate
Then, at that point, ensure that the telescope is empowered. Open config/telescope.php record and find empowered. You will see the following lines:
You can change the default worth to misleading and empower Telescope in the .env record using the following variable:
- TELESCOPE_ENABLED=true
2. Show Logged Requests
Note, that Telescope can show the solicitations performed after bundle initiation. Presently, you can make any solicitation to the Laravel project and get a 404 Not Found in Laravel. For instance:
- https://localhost:8080/test
Then, at that point, open/telescope course. In the event that your server has the location http://localhost:8080, the course will seem to be this http://localhost:8080/telescope. Here change to the Solicitations tab:
You will see all logged demands. For instance the most recent solicitation returned a 404 blunder code. Click on the eye symbol to see subtleties:
Here, you ought to investigate Middleware and Regulator Activity fields. In this model they are vacant. This implies that the switch can’t find the mentioned course. At the point when the switch finds a course, these fields will contain information about the regulator and activity handling this solicitation. For instance:
Here you can see that the solicitation was dealt with by ExampleController and index activity. This implies that the switch can find this course and assuming you get 404, the regulator tosses this blunder. It assists with understanding where the issue is and fix it.
3. Check Routes
In the event that the switch can’t find your 404 Not Found in Laravel yet you think that you have enlisted it, you can see all enrolled courses using the order underneath:
- php craftsman route:list
Assuming you have reserved courses, you ought to clear the store before you see new courses:
- php craftsman cache:clear
Additionally, consider Laravel structure has support for where() technique for courses. For instance, you can enroll the course/model/{id} where id can contain just digits from 0 to 9. At the point when you use/model/5, it will work, yet when you use/model/5a you will get a 404 mistake. If you have any desire to involve this strategy in your venture, you ought to set the critical name and customary articulation for it. For instance:
Wrapping Up
In this article we have explained how to troubleshoot 404 Not Found in Laravel. It is straightforward on the off chance that you utilize a unique tool. For instance the laravel/telescope bundle. In extra, you can involve this tool in numerous different cases, yet be cautious and empower it just for improvement.