How to combine Phaclon\Mvc\Application and Phaclon\Mvc\Micro in one project?

Stanislav Belichenko

Structure of my project:

├── apps
│   ├── backend <= Micro
│   └── frontend <= Application
├── public
│   ├── css
│   ├── index.php <= Single entry point
│   └── js
└── vendor
    ├── ...

Note: I dont want use two entry point, something like this:

├── apps
│   ├── ...
├── www
│   ├── css
│   ├── index.php <= Entry point for Frontend
│   └── js
├── api
│   ├── index.php <= <= Entry point for Backend

It is still a spare option.

Question:

  1. Tell me where I can see example of such project?
  2. If chosen way of organizing the project is wrong, what is correct one?

In both cases, I would like to get an example code for the following files:

public/index.php // or www/index.php & api/public.php
apps/forntend/Module.php // or something similar
apps/backend/Module.php // or something similar

and how I should organize work with routes, dispatcher, etc.

Nikolaos Dimopoulos

You can employ different solutions for this. Yes you can do @Juri wrote for sure but if you want your API/Backend to be as slim as possible, then you can use the Micro application.

The trick is to have an abstract bootstrap class which performs all of your initializations (including the application object) and override this with the relevant bootstrap classes for frontend, backend, cli etc.

Have a look at the Phalcon website implementation, in particular the Bootstrap class on how you can achieve this.

The implementation is explained in length in these posts:

https://blog.phalconphp.com/post/building-the-new-phalcon-website-implementation-part-1 https://blog.phalconphp.com/post/building-the-new-phalcon-website-bootstrap-part-2 https://blog.phalconphp.com/post/building-the-new-phalcon-website-middleware-part-3

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related