I
I
Igor Tarasov2020-11-01 11:47:56
Laravel
Igor Tarasov, 2020-11-01 11:47:56

Is it necessary to create a separate controller for an API in Laravel?

Question on Laravel 7. I need to make only two methods via API: is and replace.
Do I need to make a separate controller, or can they be stuffed into an existing one that the web serves?

It is clear that it is better to create. But I would like to hear specific reasons.
Well, there are 404 error codes in JSON, for example, to give.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanatPHP, 2020-11-01
@FanatPHP

No, not "necessarily".
Laravel is also optional, you can use regular spaghetti.

P
pLavrenov, 2020-11-03
@pLavrenov

My personal IMHO - it's better to use this package , all in one file, no need to create a bunch of files like validation. If necessary, you can immediately send to the queue and not create a job layer. etc

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question