I'm working on an e-commerce project using laravel-vue
for website and laravel-api
for mobile application, i wanted suggestion on the best way to manage api part
or the best way to implement the project
these are my thoughts on implementing this
1->using same controller for both api
and web
, but worried abut complex logic and scalability
public function index(Request $request)
{
$users = User::all();
if ($request->wantsJson()) {
//return json-data for mobile app
}
return view('agents', compact('users'));
}
2->creating separate namespace
for api controllers. namespace App\Http\Controllers\Api\;
3->creating just the api using laravel and create client app using vue-cli/angular2 so that the mobile app and web app can use the same api. here concerned about SEO
any suggestions are welcome
thank you
Aucun commentaire:
Enregistrer un commentaire