hexmakina / kadro
PHP MVC 框架
Requires
- php: >=7.1
- hexmakina/black-box: 0.0.*
- hexmakina/crudites: 0.0.*
- hexmakina/debugger: 0.1.*
- hexmakina/hopper: 0.1.*
- hexmakina/le-marchand: 0.1.*
- hexmakina/lezer: 0.0.*
- hexmakina/local-fs: 0.0.*
- hexmakina/log-laddy: 0.0.*
- hexmakina/marker: 0.1.*
- hexmakina/state-agent: 0.1.*
- hexmakina/tempus: 0.0.*
- hexmakina/tight-orm: 0.0.*
- hexmakina/tracer: 0.1.*
- hexmakina/traitor: 0.1.*
- smarty/smarty: 3.1.34
README
kadro
用于构建网络应用的 PHP MVC 框架
安装
composer require hexmakina/kadro
然后运行 vendor/hexmakina/kadro/install.php
以初始化应用,包括基础表和数据
例如
php vendor/hexmakina/kadro/install.php -db DATABASE_NAME -u DATABASE_USER -p DATABASE_PASSWORD
或者,如果密码包含空格
php vendor/hexmakina/kadro/install.php -db DATABASE_NAME -u DATABASE_USER -p "DATABASE_PASSWORD"
它将创建一个默认的根用户 "root",密码为 "root"
1. 认证
操作员
权限
ACL
2. 模型
PSR-3 日志记录器
PSR-4 自动加载器
3. 视图
4. 控制器
基础
显示
Kadro
ORM
接待
路由器
链环 & 情人
容器(PSR-11)
错误
基础
-
路由
-
容器 & 调用者
-
日志记录器 & 错误
-
跳鼠
-
勒马尔尚
-
情人
-
LogLaddy
处理错误、路由、日志记录和容器
执行 & 返回
要正确执行控制器方法,例如 public function doSomething()
,需要调用: $controller->execute('doSomething')
,允许执行钩子。
如果没有在钩子和情人的部分发生错误,将返回 doSomething()
的返回值。
钩子
当运行 $controller->execute('doSomething')
时,将调用以下钩子
$this->prepare()
$this->before_doSomething()
$this->doSomething()
$this->after_doSomething()
$this->conclude()
不需要实现任何调用,因为 Base 会首先检查它们的存在,关于 prepare() 和 conclude(),Base 有一个默认实现,返回 true
情人
Base 使用 Traitor 特性,并在调用控制器的特性兼容方法之前调用控制器自己的方法。
给定一个使用 Trait1 和 Trait2 的控制器,方法调用列表如下
$this->Trait1_Traitor_prepare()
$this->Trait2_Traitor_prepare()
$this->prepare()
$this->Trait1_Traitor_before_doSomething()
$this->Trait2_Traitor_before_doSomething()
$this->before_doSomething()
$this->Trait1_Traitor_doSomething()
$this->Trait2_Traitor_doSomething()
$this->doSomething()
$this->Trait1_Traitor_after_doSomething()
$this->Trait2_Traitor_after_doSomething()
$this->after_doSomething()
$this->Trait1_Traitor_conclude()
$this->Trait2_Traitor_conclude()
$this->conclude()
5. 路由
kadro 需要一个 'home' 路由
- GET ''
kadro 预留以下路由
return [
// --- auth
['GET', 'checkin', 'Reception::checkin', 'checkin'],
['GET', 'checkout', 'Reception::checkout', 'checkout'],
['POST', 'identify', 'Reception::identify', 'identify'],
['GET', 'operator/[*:username]/toggle/active', 'Operator::change_active', 'operator_change_active'],
['GET', 'operator/[*:username]/change-acl/[i:permission_id]', 'Operator::change_acl', 'acl_toggle'],
// --- TRADUKO
['POST', 'traduko/update_file', 'Traduko::update_file', 'traduko_update_file'],
// --- LOCALE JSON
['GET', 'locale/language_codes.[a:format]', 'Export::otto_languages', 'otto_languages'],
// --- EXPORT
['GET', 'export', 'Export::dashboard', 'export'], // default ExportController is dashboard
['GET', 'otto/language_codes.[a:format]/term/[a:search]?', 'Export::otto_languages', 'otto_languages_search'],
['GET', 'otto/[a:model]/distinct/[*:field].[a:format]', 'Export::otto_distinct_field', 'otto_distinct_field'],
['GET', 'otto/[a:model]/distinct/[*:field].[a:format]/term/[*:search]?', 'Export::otto_distinct_field', 'otto_distinct_field_where'],
['GET', 'export/[*:action].[a:format]', 'Export::dynamic_action_call', 'export_action_call'],
];