robopzet's avatar

routes/api.php removed in Laravel 12 use web or restore it?

to migrate an existing Laravel application I started with a fresh Laravel 12 application. The file routes/api.php no longer exists.

I put the routes, or rather custom method calls for them, in web.php. Now fixing the middleware, like no ValidateCsrfToken Session etc. Basically I'm restoring the configuration of the previous api routes.

Then I read in the docs that there is still some "magic" handling for an api group and even the older route file.

Now I wonder what is the preferred Laravel solution to go forward (and why):

  1. get rid of all code related to the api route group, use web and customize middleware per route
  2. create custom code to restore how the api group worked before
0 likes
3 replies
robopzet's avatar

Forget it, just saw that you need to use this command to let Laravel create the routes/api.php file:

php artisan install:api
9 likes

Please or to participate in this conversation.