Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

yanikkumar's avatar

How to switch from web.php routes and make them api for usage in mobile app or other website?

I've made the project in laravel and made actions in web.php file. Now I want to make api from them so that I can use them in the mobile application I'm working on, Do I need to make separate api functions or just use same routes as api?

0 likes
1 reply
Snapey's avatar
Snapey
Best Answer
Level 122

You can use the same routes within the api.web

All the routes you move across will be prefixed /api/

Make sure you have a strategy for authentication as all api routes are stateless and cannot use cookie based session authentication

1 like

Please or to participate in this conversation.