Micro Api REST + MVC Backend

Hi all, I'm trying to set up a simple application: I need a backend for editing and an API for remote usage. I'm trying to build the base project using Vokuro and Phalcon REST Boilerplate (https://github.com/redound/phalcon-rest-boilerplate) as base project. I've set up both in the same project, but i can use one or the other changing the index.php file. Vokuro is an MVC bootstrap (configured as a module), the API REST is MICRO, so the bootstrap and the routes are different. At the moment I'm using nginx aliases: every url with /api/ points to api.php (with the micro bootstrap), any other url to index.php (the default MVC). What do you suggest?

edited Mar '19

I've had something similar.

So two separate Phalcon\Mvc\Micro\Collection is the solution which will handle REST API and back-office respectively.

https://docs.phalcon.io/3.4/en/api/phalcon_mvc_micro_collection

Make sure to divide them by using setPrefix per each collection.



9.5k
edited Mar '19

Make sense. PhalconREST is based on Phalcon\Mvc\Micro\Collection. Do you use Micro collection for backoffice also? I need MVC for that. How have you managed the bootstrap and the routes for both REST API and back-office?

Well, the entire purpose of using MicroCollection is exactly that - you organize your front (user, public) routes and back-office (admin) routes.

I do use same approach for both parts as stated above. You can use MVC as well for back-office or both, I had Volt for views, Models as usual and controllers to glue them as usual.

If you need an example - just ring the bell.



9.5k

An example of how you manage the bootstrap of services, routes and loaders in one place could be usefull.

I'm also trying to merge vokuro and rest boilerplate. Have you already achieved this? I would kill for an example.

edited May '19

Of course there is a way out. There are ways to restore deleted files from any device, I personally used it. I used photo recovery on SD card https://www.diskinternals.com/uneraser/recover-deleted-photos-from-sd-card/ good program, reasonable prices, user-friendly interface. Hope this helps you.

Could you post that example please?

Well, the entire purpose of using MicroCollection is exactly that - you organize your front (user, public) routes and back-office (admin) routes.

I do use same approach for both parts as stated above. You can use MVC as well for back-office or both, I had Volt for views, Models as usual and controllers to glue them as usual.

If you need an example - just ring the bell.