[PHP] 框架概念與設計模式 – PHP各框架功能對照

Intro

PHP有眾多框架可供選擇,本篇大致會以Laravel 5、Yii 2、CodeIgniter 3做舉例與對照。


Router

Features CodeIgniter 3 Yii 2 Laravel 5
Router 有 有 有
Controller預設路由 有 有 -
Action arguments轉譯成URI 有 - -

Database/Model

Features CodeIgniter 3 Yii 2 Laravel 5
PDO 支援 支援 支援
Query Builder 有 有 有
ORM/Active Record - Active Record Eloquent
Read & Write Splitting - 有 有
Relations - 有 有
Validation - 有 有
Timestamps Behavior - 有 有
Eager Loading - 有 有
Junction Table - 有 有
Soft Deleting - - 有
Query Scopes - - 有

CodeIgniter 3 ORM yidas/codeigniter-model


View/Template

Features CodeIgniter 3 Yii 2 Laravel 5
View 有 有 有
Template Layout - 有(Pure PHP) Blade pattern
Template Engine - 不需要 Blade

Asset Manager

Features CodeIgniter 3 Yii 2 Laravel 5
Asset - 有 -
Asset Bundle - 有 -
Asset internal copy - 支援 -

DI (Dependency Injection)

Features CodeIgniter 3 Yii 2 Laravel 5
DI pattern - 有 有
Container - Container Service Container
Provider - Service Locator Service Provider
Container Singleton - 支援 支援
Central Provider - Application Component註冊 Provider Config註冊

Leave a Reply

Your email address will not be published. Required fields are marked *