Laravel 11 Create Custom Route File Tutorial

Devendra Dode
1 min readApr 7, 2024

In Laravel 11, a custom route refers to a route that you define to handle specific HTTP requests for your application endpoints. These routes are custom in the sense that you create them according to the needs and requirements of your application.

Now i will show you how to create and use custom route file in laravel 11 application.

Step 1 — Create Custom Route File

Create custom route file in routes folder.

Step 2 — Define Custom Route File

Define your custom route file in app.php file; like the following:

   health: '/up',
then: function () {
Route::namespace('Teacher')->prefix('teacher')->name('teacher.')->group(base_path('routes/teacher.php'));
},

Step 3 — Add Routes in Custom Route File

Add routes in your custom route file; like the following:

Route::get('/', function () {
return "welcome to teacher route";
});

Step 4— Test

Test your custom routes with file, use the following url on browser:

http://127.0.0.1:8000/route-file-name/route-name

That’s it. Thanks for reading.

For any reference visit https://laravel.com/docs/11.x/routing

--

--

Devendra Dode

Devendra Dode passionate full stack developer with a strong foundation in web development. With expertise in both front-end and back-end technologies.