boneill81's avatar

Regarding Routing, web.php vs api.php

Hi Guys,

Having initially began a project when routes.php was the thing and then with the move to web/api.php I wanted to ask what approaches you take.

My project has rest aspects to it for certain elements but for instance for general web services that return datatables json etc. do you use web or api.php. I realise it works in both and the difference is in the middleware that is applies and the addition of the api prefix. But I was curious do you use the api.php or do any of you recreate routes.php.

Thanks!

0 likes
3 replies
Qlic's avatar

Personally i use the web file for all things non api related, imo datatables is a 'web request' so it should be in the web route file.

GeorgeBro's avatar

What is an API? A Problematic Interpretation? Awesome Pudding Incarnate?

martinbean's avatar

@boneill81 Well, simply put, routes for an API go in your routes/api.php file and routes for your web application go in your routes/web.php file.

Please or to participate in this conversation.