Ini adalah contoh struktur file MVC yang dapat Anda gunakan menggunakan phalcon> = 3.0.x
Untuk dokumentasi lebih lanjut, lihat dokumen Phalcon.
中文简体
Ini adalah struktur MVC yang sangat sederhana, berisi satu model, dua pengontrol dan tampilan. Contoh ini tidak mengimplementasikan ruang nama. Layanan didefinisikan dalam public/index.php tanpa menggunakan DiFactoryDefault :
simple
├── apps
│ ├── controllers
│ │ ├── IndexController.php
│ │ └── ProductsController.php
│ ├── models
│ │ └── Products.php
│ └── views
│ └── products
│ └── index.phtml
└── public
└── index.php
Ini adalah struktur MVC yang sangat sederhana, berisi satu model, dua pengontrol dan tampilan. Contoh ini tidak mengimplementasikan ruang nama. Layanan didefinisikan dalam public/index.php tanpa menggunakan DiFactoryDefault . Contoh ini menggunakan volt sebagai mesin template:
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
Struktur MVC lainnya yang sangat sederhana, berisi satu model, tiga pengontrol dan tampilan. Rute didefinisikan dalam app/config/routes.php . Beberapa rute menunjuk ke pengontrol dalam subdirektori 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
Struktur MVC sederhana tanpa menggunakan PhalconMvcApplication . Aplikasi ini tidak menggunakan ruang nama. Ini adalah contoh bagaimana Anda dapat mengganti PhalconMvcApplication dengan mengimplementasikan fungsionalitas yang serupa. Ini juga mendefinisikan layanan tanpa menggunakan DiFactoryDefault di public/index.php :
simple-without-application/
├── apps
│ ├── controllers
│ │ ├── IndexController.php
│ │ └── ProductsController.php
│ ├── models
│ │ └── Products.php
│ └── views
│ └── products
│ └── index.phtml
└── public
└── index.php
Ini struktur MVC modul tunggal tanpa ruang nama. Anda dapat menemukan direktori modul di bawah apps/ direktori. Contoh ini tidak menggunakan ruang nama. Semua layanan diinisialisasi di public/index.php . Juga, dalam file ini, Anda juga dapat menemukan kelas aplikasi yang menginisialisasi layanan dan autoloader mengelompokkan tugas -tugas ini dengan metode.
single
├── apps
│ ├── controllers
│ │ ├── IndexController.php
│ │ └── ProductsController.php
│ ├── models
│ │ └── Products.php
│ └── views
│ ├── index.phtml
│ └── products
│ ├── index.phtml
│ └── test.phtml
└── public
└── index.php
Ini struktur MVC modul tunggal menggunakan namespaces. Anda dapat menemukan direktori modul di bawah apps/ direktori. Contoh ini memang menggunakan ruang nama. Semua layanan diinisialisasi di public/index.php . Juga, dalam file ini, Anda juga dapat menemukan kelas aplikasi yang menginisialisasi layanan dan autoloader mengelompokkan tugas -tugas ini dengan metode.
single-namespaces/
├── apps
│ ├── controllers
│ │ ├── IndexController.php
│ │ └── ProductsController.php
│ ├── models
│ │ └── Products.php
│ └── views
│ └── products
│ └── index.phtml
└── public
└── index.php
Struktur MVC modul tunggal seperti yang dihasilkan oleh alat pengembang Phalcon. Alih -alih menginisialisasi setiap layanan secara individual, ia menggunakan 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
Ini struktur MVC modul tunggal. Semua file dan direktori disamarkan (termasuk tampilan):
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
Ini struktur MVC modul tunggal yang menunjukkan cara mendaftarkan layanan non-standar:
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
Ini struktur MVC multi-modul. Contoh ini mengimplementasikan dua modul: Frontend and Backend. Secara default Frontend dilayani jika tidak ada rute ke backend yang diminta. Anda dapat mendefinisikan rute mana yang menggunakan satu modul atau lainnya di 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
Ini struktur MVC multi-modul. Contoh ini mengimplementasikan dua modul: Frontend and Backend. Secara default Frontend dilayani jika tidak ada rute ke backend yang diminta. Anda dapat menentukan rute mana yang menggunakan satu modul atau lainnya di public/index.php . Volt digunakan sebagai mesin template:
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
Ini struktur MVC multi-modul dengan direktori tampilan umum:
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
Ini struktur MVC multi-modul seperti yang dihasilkan oleh alat pengembang Phalcon:
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
Struktur MVC multi-modul ini dengan pola lapisan layanan model diimplementasikan:
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
Aplikasi seperti mikro-seperti:
micro
└── index.php
Aplikasi seperti mikro-seperti yang dihasilkan oleh alat pengembang Phalcon:
micro-factory-default/
├── config
│ └── config.php
├── index.html
├── public
│ └── index.php
└── views
├── 404.phtml
└── index.phtml
Aplikasi seperti mikro-seperti di mana tampilan diberikan menggunakan PhalconMvcViewSimple :
micro-simple-views
├── config
│ ├── config.php
│ └── services.php
├── index.php
└── views
├── 404.volt
├── 500.volt
└── index.volt
Contoh Phalcon MVC adalah perangkat lunak open source yang dilisensikan di bawah lisensi BSD yang baru. Lihat file lisensi.txt untuk lebih lanjut.
Hak Cipta (C) 2011-2016, Tim Kerangka Phalcon