What is the route directory in Laravel?

widget

Understanding the route directory in Laravel

All of the routes that you define in your application will be in the route directory. By default, Laravel starts with some route files: web.php, api.php, console.php, and channels.php.

web.php

The web.php file is where you will probably have all of your route definitions. The web.php file contains routes that the RouteServiceProvider places within the web middleware bunch, which gives session state, CSRF security, and cookie encryption. This happens in the event that your application does not offer a stateless Restful API.

api.php

The api.php file has routes that the RouteServiceProvider places within the API middleware bunch. These routes aim to be stateless, so requests that enter the application through these routes aim to be authenticated through tokens and will not have access to the session state.

console.php

The console.php file basically defines console-based entry points. It contains all of the closure-based console commands.

channels.php

The channels.php file is where you can register all of your Eventbraodcasting channels that your application supports.

Conclusion

These are the four files found in the route directory in Laravel by default.

Free Resources