如何在一个项目中合并 Phaclon\Mvc\Application 和 Phaclon\Mvc\Micro?
How to combine Phaclon\Mvc\Application and Phaclon\Mvc\Micro in one project?
我的项目结构:
├── apps
│ ├── backend <= Micro
│ └── frontend <= Application
├── public
│ ├── css
│ ├── index.php <= Single entry point
│ └── js
└── vendor
├── ...
注意:我不想使用两个入口点,像这样:
├── apps
│ ├── ...
├── www
│ ├── css
│ ├── index.php <= Entry point for Frontend
│ └── js
├── api
│ ├── index.php <= <= Entry point for Backend
还是备用选项
问题:
- 告诉我在哪里可以看到此类项目的示例?
- 如果选择的组织项目的方式是错误的,那么正确的是什么?
在这两种情况下,我都想获取以下文件的示例代码:
public/index.php // or www/index.php & api/public.php
apps/forntend/Module.php // or something similar
apps/backend/Module.php // or something similar
以及我应该如何使用路由、调度程序等来组织工作
为什么要合并它们?单独使用 Phalcon\Mvc\Application
即可。 Micro 甚至没有调度程序、模块等。Phalcon\Mvc\Micro
是独立的东西,不应在 Phalcon\Mvc\Application
.
的同一应用程序中使用
你到底想达到什么目的?
您可以为此采用不同的解决方案。是的,你可以做到 @Juri 写的肯定,但如果你希望你的 API/Backend 尽可能苗条,那么你可以使用 Micro 应用程序。
诀窍是有一个抽象 bootstrap class 执行所有初始化(包括应用程序对象)并用相关的 bootstrap class 覆盖它es 用于前端、后端、cli 等
查看 Phalcon 网站实施,特别是 Bootstrap class 了解如何实现此目的。
在这些帖子中详细解释了实现:
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
我的项目结构:
├── apps
│ ├── backend <= Micro
│ └── frontend <= Application
├── public
│ ├── css
│ ├── index.php <= Single entry point
│ └── js
└── vendor
├── ...
注意:我不想使用两个入口点,像这样:
├── apps
│ ├── ...
├── www
│ ├── css
│ ├── index.php <= Entry point for Frontend
│ └── js
├── api
│ ├── index.php <= <= Entry point for Backend
还是备用选项
问题:
- 告诉我在哪里可以看到此类项目的示例?
- 如果选择的组织项目的方式是错误的,那么正确的是什么?
在这两种情况下,我都想获取以下文件的示例代码:
public/index.php // or www/index.php & api/public.php
apps/forntend/Module.php // or something similar
apps/backend/Module.php // or something similar
以及我应该如何使用路由、调度程序等来组织工作
为什么要合并它们?单独使用 Phalcon\Mvc\Application
即可。 Micro 甚至没有调度程序、模块等。Phalcon\Mvc\Micro
是独立的东西,不应在 Phalcon\Mvc\Application
.
你到底想达到什么目的?
您可以为此采用不同的解决方案。是的,你可以做到 @Juri 写的肯定,但如果你希望你的 API/Backend 尽可能苗条,那么你可以使用 Micro 应用程序。
诀窍是有一个抽象 bootstrap class 执行所有初始化(包括应用程序对象)并用相关的 bootstrap class 覆盖它es 用于前端、后端、cli 等
查看 Phalcon 网站实施,特别是 Bootstrap class 了解如何实现此目的。
在这些帖子中详细解释了实现:
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