Reputation: 566
I am very new to Laravel 5 and PHP namespaces. I am creating an API for a website. This API will connect with other API's and create a connection with DB server.
I would like to create effective namespaces for the following structure:
Models:
Base.php, Category.php, Order.php, Product.php
Controllers:
OrderController.php, CategoyController.php,OrderController.php,ProductController.php
Base.php will call other API's.
Category.php, Order.php & Product.php will do all the operations on category, order and product table.
While all controllers will handle the request from the routes, call their respective models or other models(if required) and returns the output in JSON form.
If you require more information, please comment.
Upvotes: 0
Views: 170
Reputation: 2981
Use the standard namespacing:
- Models go under: App
- Controllers go under: App\Http\Controllers
If you are serving both web and api on the same server; hence split controllers:
- Web: App\Http\Controllers
- Api: App\Http\Controllers\Api
I would not recommend changing that, as that's what the other developers expect from your application.
Upvotes: 1