M
M
Mo1she2018-08-10 05:56:23
Laravel
Mo1she, 2018-08-10 05:56:23

api.php and web.php in laravel?

Hello. Tell me in which cases it is worth defining routes in api.php, and in which in web.php. It is clear that the difference is only in the addition of the 'api' prefix, but what is the conceptual difference? Should I make all ajax requests and all interactions with data by working with api? But only in the case when I just need to give the view to use web.php?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2018-08-10
@Mo1she

It is clear that the difference is only in the addition of the 'api' prefix, but what is the conceptual difference?
The difference is not just the addition of the prefix. Different middleware groups apply to these routes (they are described in your RouteServiceProvider). This, in general, is the answer to your question - choose based on the required middleware.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question