{"id":13805350,"url":"https://github.com/phalcon/mvc","last_synced_at":"2025-05-13T19:30:47.286Z","repository":{"id":4257165,"uuid":"5383579","full_name":"phalcon/mvc","owner":"phalcon","description":"Phalcon MVC Examples","archived":false,"fork":false,"pushed_at":"2023-07-14T08:51:37.000Z","size":201,"stargazers_count":822,"open_issues_count":4,"forks_count":323,"subscribers_count":116,"default_branch":"master","last_synced_at":"2024-11-18T21:47:16.265Z","etag":null,"topics":["mvc-pattern","phalcon-mvc","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"heroku/node-js-getting-started","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phalcon.png","metadata":{"files":{"readme":"README-CN.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2012-08-11T21:24:57.000Z","updated_at":"2024-11-16T23:33:25.000Z","dependencies_parsed_at":"2024-01-03T02:24:37.257Z","dependency_job_id":"276a096c-879c-407b-8f86-a2534b6ee05c","html_url":"https://github.com/phalcon/mvc","commit_stats":{"total_commits":82,"total_committers":18,"mean_commits":4.555555555555555,"dds":0.6829268292682926,"last_synced_commit":"277e2f6d53b70d219eb97ca6df60e9280aea08f4"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phalcon%2Fmvc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phalcon%2Fmvc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phalcon%2Fmvc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phalcon%2Fmvc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phalcon","download_url":"https://codeload.github.com/phalcon/mvc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254012968,"owners_count":21999346,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mvc-pattern","phalcon-mvc","php"],"created_at":"2024-08-04T01:01:00.304Z","updated_at":"2025-05-13T19:30:46.693Z","avatar_url":"https://github.com/phalcon.png","language":"PHP","funding_links":[],"categories":["Application Skeleton"],"sub_categories":[],"readme":"# Phalcon MVC 示例\n\n这些是您可以使用Phalcon \u003e= 3.0.x使用的[MVC][MVC -pattern]文件结构的示例要了解更多的文档，请查看[Phalcon文档](https://docs.phalconphp.com/)。\n\n## 简单的\n\n\n这是一个非常简单的[MVC][mvc-pattern]结构,它包含一个模型,两个控制器和一个视图.\n这个示例没有命名空间.服务在`public/index.php`中使用`Di\\FactoryDefault`定义:\n\n```\nsimple\n├── apps\n│   ├── controllers\n│   │   ├── IndexController.php\n│   │   └── ProductsController.php\n│   ├── models\n│   │   └── Products.php\n│   └── views\n│       └── products\n│           └── index.phtml\n└── public\n    └── index.php\n```\n\n## 简单Volt示例\n\nThis is a very simple [MVC][mvc-pattern] structure, it contains one model, two controllers and a view.\nThis example does not implement namespaces. Services are defined in `public/index.php`\nwithout using `Di\\FactoryDefault`. This example uses Volt as template engine:\n\n这是一个非常简单的[MVC][mvc-pattern]示例,它包含一个模型,两个控制器和一个视图.\n这个示例没有命名空间.服务在`public/index.php`中使用`Di\\FactoryDefault`定义.\n这个示例使用Volt模板引擎:\n\n```\nsimple-volt/\n├── app\n│   ├── config\n│   │   ├── config.php\n│   │   ├── loader.php\n│   │   └── services.php\n│   ├── controllers\n│   │   ├── ControllerBase.php\n│   │   └── IndexController.php\n│   └── views\n│       ├── index\n│       │   ├── index.volt\n│       │   └── test.volt\n│       ├── index.volt\n│       └── layouts\n│           └── template.volt\n├── index.html\n└── public\n    └── index.php\n```\n\n## Simple-Subcontrollers\n\n这是一个简单的[MVC][mvc-pattern]示例,它包含一个模型,三个控制器和一个视图.\n路由在`app/config/routes.php`中定义.一些路由指向一个控制器`controllers/`的子目录:\n\n```\nsimple-subcontrollers/\n├── app\n│   ├── config\n│   │   ├── config.php\n│   │   ├── loader.php\n│   │   ├── routes.php\n│   │   └── services.php\n│   ├── controllers\n│   │   ├── ControllerBase.php\n│   │   ├── UsersController.php\n│   │   └── admin\n│   │       ├── ControllerBase.php\n│   │       └── UsersController.php\n│   └── views\n│       ├── admin\n│       │   └── users\n│       │       └── index.volt\n│       ├── index\n│       │   └── index.volt\n│       ├── index.volt\n│       └── users\n│           └── index.volt\n├── index.html\n└── public\n    └── index.php\n```\n\n## Simple-Without-Application\n\n一个简单的[MVC][mvc-pattern]结构没有使用了 `Phalcon\\Mvc\\Application` .\n这个示例没有命名空间.讲的是如何实现类似于 `Phalcon\\Mvc\\Application` 的功能来替代它.\n它还在 `public/index.php` 中定了了依赖注入,用于替换 `Di\\FactoryDefault` (**注入工厂/预定义依赖注入**).\n\n```\nsimple-without-application/\n├── apps\n│   ├── controllers\n│   │   ├── IndexController.php\n│   │   └── ProductsController.php\n│   ├── models\n│   │   └── Products.php\n│   └── views\n│       └── products\n│           └── index.phtml\n└── public\n    └── index.php\n```\n\n## Single\n\n这是一个没有命名空间的单模块 [MVC][mvc-pattern] 结构.你可以找到一个模块目录在 `apps/` 文件夹下.\n这个示例没有命名空间.所有的服务在 `public/index.php` 中进行初始化.\n此外,在这个文件中你还可以找到一个 `Application` 类,这个类初始化了服务和自动加载器,并按照功能进行了方法定义.\n\n```\nsingle\n├── apps\n│   ├── controllers\n│   │   ├── IndexController.php\n│   │   └── ProductsController.php\n│   ├── models\n│   │   └── Products.php\n│   └── views\n│       ├── index.phtml\n│       └── products\n│           ├── index.phtml\n│           └── test.phtml\n└── public\n    └── index.php\n```\n\n## Single-Namespaces\n\n这是一个采用了命名空间的单模块 [MVC][mvc-pattern] 结构.你可以找到一个模块目录在 `apps/` 文件夹下.\n这个示例使用了命名空间.所有的服务在 `public/index.php` 中进行初始化.\n此外,在这个文件中你还可以找到一个 `Application` 类,这个类初始化了服务和自动加载器,并按照功能进行了方法定义.\n\n\n```\nsingle-namespaces/\n├── apps\n│   ├── controllers\n│   │   ├── IndexController.php\n│   │   └── ProductsController.php\n│   ├── models\n│   │   └── Products.php\n│   └── views\n│       └── products\n│           └── index.phtml\n└── public\n    └── index.php\n```\n\n## Single-Factory-Default\n\nA single-module [MVC][mvc-pattern] structure as is generated by [Phalcon Developer Tools][devtools].\nInstead of initialize every service individually, it uses `Di\\FactoryDefault`:\n\n由 [Phalcon开发工具][devtools] 生成的单模块 [MVC][mvc-pattern] 结构.\n它没有单独的去初始化服务,而是采用了 `Di\\FactoryDefalut` :\n\n```\nsingle-factory-default/\n├── app\n│   ├── config\n│   │   └── config.php\n│   ├── controllers\n│   │   ├── ControllerBase.php\n│   │   ├── IndexController.php\n│   │   └── TestController.php\n│   └── views\n│       ├── index\n│       │   └── index.phtml\n│       └── index.phtml\n├── index.html\n└── public\n    └── index.php\n```\n\n## Single-Camelized-Dirs\n\n这是一个单模块 [MVC][mvcpattern] 结构。所有文件和目录都被驼峰化(包括视图):\n\n```\nsingle-camelized-dirs/\n├── App\n│   ├── Config\n│   │   ├── Loader.php\n│   │   └── Services.php\n│   ├── Controllers\n│   │   ├── IndexController.php\n│   │   └── ProductsController.php\n│   ├── Models\n│   │   └── Products.php\n│   └── Views\n│       ├── Index\n│       │   └── Index.phtml\n│       └── Products\n│           └── Index.phtml\n└── public\n    └── index.php\n```\n\n## Single-Service-Provider\n\n这是一个单模块[MVC][mvc-pattern]结构，显示了一种非标准的服务注册方式:\n\n```\nsingle-service-provider/\n├── app\n│   ├── Bootstrap.php\n│   ├── Http\n│   │   ├── Controllers\n│   │   │   ├── Controller.php\n│   │   │   └── IndexController.php\n│   │   └── routes.php\n│   ├── Models\n│   └── Providers\n│       ├── AbstractServiceProvider.php\n│       ├── ConfigServiceProvider.php\n│       ├── DatabaseServiceProvider.php\n│       ├── EscaperServiceProvider.php\n│       ├── EventManagerServiceProvider.php\n│       ├── ModelsMetadataServiceProvider.php\n│       ├── MvcDispatcherServiceProvider.php\n│       ├── PhpTemplateEngineServiceProvider.php\n│       ├── ResponseServiceProvider.php\n│       ├── RouterServiceProvider.php\n│       ├── ServiceProviderInterface.php\n│       ├── SessionServiceProvider.php\n│       ├── TagServiceProvider.php\n│       ├── UrlResolverServiceProvider.php\n│       ├── ViewServiceProvider.php\n│       └── VoltTemplateEngineServiceProvider.php\n├── bootstrap\n│   └── autoload.php\n├── config\n│   ├── application.php\n│   └── providers.php\n├── index.html\n├── public\n│   └── index.php\n├── resources\n│   └── views\n│       ├── index\n│       │   └── index.volt\n│       ├── index.volt\n│       └── partials\n│           └── content.volt\n└── storage\n    ├── cache\n    │   ├── data\n    │   └── volt\n    └── logs\n```\n\n## Multiple\n\nThis a multi-module [MVC][mvc-pattern] structure..\nYou can define which routes use one module or another in `public/index.php`:\n\n这是一个多模块 [MVC][mvc-pattern] 结构.这个例子实现了两个模块:前端和后端.\n默认情况下，如果不要求路由到后端，则提供前端.\n你可以在 `public/index.php` 定义一些路由使用一个模块或者自定义模块.\n\n```\nmultiple/\n├── apps\n│   ├── backend\n│   │   ├── Module.php\n│   │   ├── controllers\n│   │   │   ├── IndexController.php\n│   │   │   ├── LoginController.php\n│   │   │   └── ProductsController.php\n│   │   ├── models\n│   │   │   └── Products.php\n│   │   └── views\n│   │       ├── login\n│   │       │   └── index.phtml\n│   │       └── products\n│   │           └── index.phtml\n│   └── frontend\n│       ├── Module.php\n│       ├── controllers\n│       │   ├── IndexController.php\n│       │   ├── ProductsController.php\n│       │   └── UsersController.php\n│       ├── models\n│       │   └── Products.php\n│       └── views\n│           ├── index\n│           │   └── index.phtml\n│           └── products\n│               └── index.phtml\n└── public\n    └── index.php\n```\n\n## Multiple-Volt\n\n这是一个多模块的使用了 Vole模板引擎的 [MVC][mvc-pattern] 结构.这个例子实现了两个模块:前端和后端.\n默认情况下，如果不要求路由到后端，则提供前端.\n你可以在 `public/index.php` 定义一些路由使用一个模块或者自定义模块.\n模板引擎使用的是 Volt:\n\n```\nmultiple-volt/\n├── apps\n│   └── frontend\n│       ├── Module.php\n│       ├── config\n│       │   └── config.php\n│       ├── controllers\n│       │   ├── ControllerBase.php\n│       │   └── IndexController.php\n│       └── views\n│           ├── index\n│           │   ├── index.volt\n│           ├── index.volt\n├── config\n│   ├── modules.php\n│   └── services.php\n├── index.html\n└── public\n    └── index.php\n```\n\n## Multiple-Shared-Views\n\n这是一个多模块[MVC][MVC -pattern]结构，有一个主视图目录:\n\n```\nmultiple-shared-views/\n├── apps\n│   ├── common\n│   │   └── views\n│   │       ├── index\n│   │       │   └── index.phtml\n│   │       ├── index.phtml\n│   │       └── products\n│   │           └── index.phtml\n│   └── modules\n│       ├── backend\n│       │   ├── Module.php\n│       │   ├── controllers\n│       │   │   ├── IndexController.php\n│       │   │   └── ProductsController.php\n│       │   └── models\n│       │       └── Products.php\n│       └── frontend\n│           ├── Module.php\n│           └── controllers\n│               └── IndexController.php\n└── public\n    └── index.php\n```\n\n## Multiple-Factory-Default\n\n这是一个多模块[MVC][mvc-pattern]结构，由[Phalcon Developer Tools][devtools]生成:\n\n```\nmultiple-factory-default/\n├── apps\n│   └── frontend\n│       ├── Module.php\n│       ├── config\n│       │   └── config.php\n│       ├── controllers\n│       │   ├── ControllerBase.php\n│       │   └── IndexController.php\n│       └── views\n│           ├── index\n│           │   └── index.phtml\n│           └── index.phtml\n├── index.html\n└── public\n    └── index.ph\n```\n\n\n## Multiple-Service-Layer-Model\n\n这是一个多模板的 [MVC][mvc-pattern]目录结构,它实现了服务层.\n\n```\nmultiple-service-layer-model/\n├── apps\n│   ├── config\n│   │   ├── config.php\n│   │   ├── modules.php\n│   │   └── services.php\n│   ├── models\n│   │   ├── entities\n│   │   │   └── User.php\n│   │   ├── repositories\n│   │   │   ├── Exceptions\n│   │   │   │   └── InvalidRepositoryException.php\n│   │   │   ├── Repositories.php\n│   │   │   └── Repository\n│   │   │       └── User.php\n│   │   └── services\n│   │       ├── Exceptions\n│   │       │   └── InvalidServiceException.php\n│   │       ├── Service\n│   │       │   └── User.php\n│   │       └── Services.php\n│   └── modules\n│       └── frontend\n│           ├── Module.php\n│           ├── controllers\n│           │   ├── ControllerBase.php\n│           │   └── IndexController.php\n│           └── views\n│               ├── index\n│               │   └── index.phtml\n│               └── index.phtml\n├── database.sql\n├── index.html\n├── public\n│   └── index.php\n└── tests\n    ├── Services\n    │   └── UserServiceTest.php\n    ├── TestHelper.php\n    ├── UnitTestCase.php\n    └── phpunit.xml\n```\n\n## Micro\n\n这是一个似于微框架的应用程序示例:\n\n```\nmicro\n└── index.php\n```\n\n## Micro-Factory-Default\n\n由[Phalcon开发工具][devtools]生成的类似于微框架的应用程序:\n\n```\nmicro-factory-default/\n├── config\n│   └── config.php\n├── index.html\n├── public\n│   └── index.php\n└── views\n    ├── 404.phtml\n    └── index.phtml\n```\n\n## Micro-Simple-Views\n\n一个类似于微框架的应用程序，其中的视图是使用 `Phalcon\\Mvc\\View\\Simple` 呈现的:\n\n```\nmicro-simple-views\n├── config\n│   ├── config.php\n│   └── services.php\n├── index.php\n└── views\n    ├── 404.volt\n    ├── 500.volt\n    └── index.volt\n```\n\n## License\n\nPhalcon MVC Examples is open source software licensed under the New BSD License.\nSee the LICENSE.txt file for more. \u003cbr\u003e\nCopyright (c) 2011-2016, Phalcon Framework Team\n\n[devtools]: https://github.com/phalcon/phalcon-devtools\n[mvc-pattern]: https://en.wikipedia.org/wiki/Model–view–controller\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphalcon%2Fmvc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphalcon%2Fmvc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphalcon%2Fmvc/lists"}