這些是您可以使用phalcon> = 3.0.x使用的MVC文件結構的示例
有關進一步的文檔,請查看Phalcon文檔。
中文簡體
這是一個非常簡單的MVC結構,它包含一個模型,兩個控制器和一個視圖。此示例不實現名稱空間。服務是在public/index.php中定義的,而無需使用DiFactoryDefault :
simple
├── apps
│ ├── controllers
│ │ ├── IndexController.php
│ │ └── ProductsController.php
│ ├── models
│ │ └── Products.php
│ └── views
│ └── products
│ └── index.phtml
└── public
└── index.php
這是一個非常簡單的MVC結構,它包含一個模型,兩個控制器和一個視圖。此示例不實現名稱空間。服務在不使用DiFactoryDefault情況下在public/index.php中定義。此示例將Volt用作模板引擎:
simple-volt/
├── app
│ ├── config
│ │ ├── config.php
│ │ ├── loader.php
│ │ └── services.php
│ ├── controllers
│ │ ├── ControllerBase.php
│ │ └── IndexController.php
│ └── views
│ ├── index
│ │ ├── index.volt
│ │ └── test.volt
│ ├── index.volt
│ └── layouts
│ └── template.volt
├── index.html
└── public
└── index.php
另一個非常簡單的MVC結構,它包含一個模型,三個控制器和一個視圖。路由是在app/config/routes.php中定義的。一些路線指向控制器子目錄中的controllers/ :
simple-subcontrollers/
├── app
│ ├── config
│ │ ├── config.php
│ │ ├── loader.php
│ │ ├── routes.php
│ │ └── services.php
│ ├── controllers
│ │ ├── ControllerBase.php
│ │ ├── UsersController.php
│ │ └── admin
│ │ ├── ControllerBase.php
│ │ └── UsersController.php
│ └── views
│ ├── admin
│ │ └── users
│ │ └── index.volt
│ ├── index
│ │ └── index.volt
│ ├── index.volt
│ └── users
│ └── index.volt
├── index.html
└── public
└── index.php
簡單的MVC結構而無需使用PhalconMvcApplication 。此應用程序不使用名稱空間。這是如何通過實現類似功能來覆蓋PhalconMvcApplication的一個示例。它還可以在不使用DiFactoryDefault中的public/index.php中定義服務:
simple-without-application/
├── apps
│ ├── controllers
│ │ ├── IndexController.php
│ │ └── ProductsController.php
│ ├── models
│ │ └── Products.php
│ └── views
│ └── products
│ └── index.phtml
└── public
└── index.php
這是一個沒有名稱空間的單模塊MVC結構。您可以在apps/目錄下找到模塊的目錄。此示例不使用名稱空間。所有服務均以public/index.php初始化。另外,在此文件中,您還可以找到一個應用程序類,該類別初始化服務和自動加載器,通過方法對這些任務進行分組。
single
├── apps
│ ├── controllers
│ │ ├── IndexController.php
│ │ └── ProductsController.php
│ ├── models
│ │ └── Products.php
│ └── views
│ ├── index.phtml
│ └── products
│ ├── index.phtml
│ └── test.phtml
└── public
└── index.php
這是使用名稱空間的單模塊MVC結構。您可以在apps/目錄下找到模塊的目錄。此示例確實使用了名稱空間。所有服務均以public/index.php初始化。另外,在此文件中,您還可以找到一個應用程序類,該類別初始化服務和自動加載器,通過方法對這些任務進行分組。
single-namespaces/
├── apps
│ ├── controllers
│ │ ├── IndexController.php
│ │ └── ProductsController.php
│ ├── models
│ │ └── Products.php
│ └── views
│ └── products
│ └── index.phtml
└── public
└── index.php
Phalcon開發人員工俱生成的單模塊MVC結構。它沒有單獨初始化每個服務,而是使用DiFactoryDefault :
single-factory-default/
├── app
│ ├── config
│ │ └── config.php
│ ├── controllers
│ │ ├── ControllerBase.php
│ │ ├── IndexController.php
│ │ └── TestController.php
│ └── views
│ ├── index
│ │ └── index.phtml
│ └── index.phtml
├── index.html
└── public
└── index.php
這是單模塊MVC結構。所有文件和目錄都是駱駝的(包括視圖):
single-camelized-dirs/
├── App
│ ├── Config
│ │ ├── Loader.php
│ │ └── Services.php
│ ├── Controllers
│ │ ├── IndexController.php
│ │ └── ProductsController.php
│ ├── Models
│ │ └── Products.php
│ └── Views
│ ├── Index
│ │ └── Index.phtml
│ └── Products
│ └── Index.phtml
└── public
└── index.php
這是一種單模型MVC結構,顯示了一種非標準的註冊服務方式:
single-service-provider/
├── app
│ ├── Bootstrap.php
│ ├── Http
│ │ ├── Controllers
│ │ │ ├── Controller.php
│ │ │ └── IndexController.php
│ │ └── routes.php
│ ├── Models
│ └── Providers
│ ├── AbstractServiceProvider.php
│ ├── ConfigServiceProvider.php
│ ├── DatabaseServiceProvider.php
│ ├── EscaperServiceProvider.php
│ ├── EventManagerServiceProvider.php
│ ├── ModelsMetadataServiceProvider.php
│ ├── MvcDispatcherServiceProvider.php
│ ├── PhpTemplateEngineServiceProvider.php
│ ├── ResponseServiceProvider.php
│ ├── RouterServiceProvider.php
│ ├── ServiceProviderInterface.php
│ ├── SessionServiceProvider.php
│ ├── TagServiceProvider.php
│ ├── UrlResolverServiceProvider.php
│ ├── ViewServiceProvider.php
│ └── VoltTemplateEngineServiceProvider.php
├── bootstrap
│ └── autoload.php
├── config
│ ├── application.php
│ └── providers.php
├── index.html
├── public
│ └── index.php
├── resources
│ └── views
│ ├── index
│ │ └── index.volt
│ ├── index.volt
│ └── partials
│ └── content.volt
└── storage
├── cache
│ ├── data
│ └── volt
└── logs
這是多模塊的MVC結構。此示例實現了兩個模塊:前端和後端。默認情況下,如果沒有要求後端的途徑,則將提供前端。您可以在public/index.php中定義哪些路線使用一個或另一種模塊:
multiple/
├── apps
│ ├── backend
│ │ ├── Module.php
│ │ ├── controllers
│ │ │ ├── IndexController.php
│ │ │ ├── LoginController.php
│ │ │ └── ProductsController.php
│ │ ├── models
│ │ │ └── Products.php
│ │ └── views
│ │ ├── login
│ │ │ └── index.phtml
│ │ └── products
│ │ └── index.phtml
│ └── frontend
│ ├── Module.php
│ ├── controllers
│ │ ├── IndexController.php
│ │ ├── ProductsController.php
│ │ └── UsersController.php
│ ├── models
│ │ └── Products.php
│ └── views
│ ├── index
│ │ └── index.phtml
│ └── products
│ └── index.phtml
└── public
└── index.php
這是多模塊的MVC結構。此示例實現了兩個模塊:前端和後端。默認情況下,如果沒有要求後端的途徑,則將提供前端。您可以在public/index.php中定義哪些路由使用一個模塊或另一個模塊。伏特用作模板引擎:
multiple-volt/
├── apps
│ └── frontend
│ ├── Module.php
│ ├── config
│ │ └── config.php
│ ├── controllers
│ │ ├── ControllerBase.php
│ │ └── IndexController.php
│ └── views
│ ├── index
│ │ ├── index.volt
│ ├── index.volt
├── config
│ ├── modules.php
│ └── services.php
├── index.html
└── public
└── index.php
這是具有共同視圖目錄的多模塊MVC結構:
multiple-shared-views/
├── apps
│ ├── common
│ │ └── views
│ │ ├── index
│ │ │ └── index.phtml
│ │ ├── index.phtml
│ │ └── products
│ │ └── index.phtml
│ └── modules
│ ├── backend
│ │ ├── Module.php
│ │ ├── controllers
│ │ │ ├── IndexController.php
│ │ │ └── ProductsController.php
│ │ └── models
│ │ └── Products.php
│ └── frontend
│ ├── Module.php
│ └── controllers
│ └── IndexController.php
└── public
└── index.php
這是Phalcon開發人員工俱生成的多模塊MVC結構:
multiple-factory-default/
├── apps
│ └── frontend
│ ├── Module.php
│ ├── config
│ │ └── config.php
│ ├── controllers
│ │ ├── ControllerBase.php
│ │ └── IndexController.php
│ └── views
│ ├── index
│ │ └── index.phtml
│ └── index.phtml
├── index.html
└── public
└── index.ph
這是實現模型服務層模式的多模塊MVC結構:
multiple-service-layer-model/
├── apps
│ ├── config
│ │ ├── config.php
│ │ ├── modules.php
│ │ └── services.php
│ ├── models
│ │ ├── entities
│ │ │ └── User.php
│ │ ├── repositories
│ │ │ ├── Exceptions
│ │ │ │ └── InvalidRepositoryException.php
│ │ │ ├── Repositories.php
│ │ │ └── Repository
│ │ │ └── User.php
│ │ └── services
│ │ ├── Exceptions
│ │ │ └── InvalidServiceException.php
│ │ ├── Service
│ │ │ └── User.php
│ │ └── Services.php
│ └── modules
│ └── frontend
│ ├── Module.php
│ ├── controllers
│ │ ├── ControllerBase.php
│ │ └── IndexController.php
│ └── views
│ ├── index
│ │ └── index.phtml
│ └── index.phtml
├── database.sql
├── index.html
├── public
│ └── index.php
└── tests
├── Services
│ └── UserServiceTest.php
├── TestHelper.php
├── UnitTestCase.php
└── phpunit.xml
類似於微型工程的應用程序:
micro
└── index.php
Phalcon開發人員工俱生成的類似於微型工作的應用程序:
micro-factory-default/
├── config
│ └── config.php
├── index.html
├── public
│ └── index.php
└── views
├── 404.phtml
└── index.phtml
一種類似於微型工作的應用程序,其中使用PhalconMvcViewSimple呈現視圖:
micro-simple-views
├── config
│ ├── config.php
│ └── services.php
├── index.php
└── views
├── 404.volt
├── 500.volt
└── index.volt
Phalcon MVC示例是根據新的BSD許可證許可的開源軟件。有關更多信息,請參見許可證文件。
版權(C)2011-2016,Phalcon框架團隊