currently I have a standard Laravel 5 proyect, eg:
Laravel Directory
app Directory
bootstrap Directory
config Directory
database Directory
public Directory
resources Directory
routes Directory
storage Directory
tests Directory
vendor Directory
what I'm trying to do is to take the public and resources folder out from the application and put it them on a different project, and in that way I'll use the laravel part only for backend purposes and the frontend parte I'll manage it on an outside project. e.g.:
Laravel Directory
app Directory
bootstrap Directory
config Directory
database Directory
routes Directory
storage Directory
tests Directory
vendor Directory
Frontend project
index.html
app folder
css folder
assets
Any recomendation or ideas to do it ?
Removing (or moving) the Public folder is not a good idea, especially due to the fact that the public/index.php
file is the entrypoint for the application.
I personally use both laravel and lumen for a bunch of my REST-API's and it works great, so that thought is not at all wrong.
Just ignore the views, don't use them and don't expose them from any controller action, but rather return all data from the controllers as JSON
instead.
This is easily done from the controller actions like:
public function getSomethingAction() {
return response()->json([
"some" => "property"
]);
}
// Which will produce the following json (including headers and all):
{
"some": "property"
}
I would also recommend that you group
your routes under a API namespace of some sort:
Route::group(["prefix" => "api/v1"], function() {
Route::get('something'...
});
So now when you call domain.tdl/api/v1/something
you will get a neat json response!