scalpel / core
我的PHP应用程序的核心组件
dev-master
2019-04-24 06:34 UTC
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2024-09-24 21:39:42 UTC
README
一些基础php组件
- 配置
- 缓存
- 动态方法管理
- 调试工具
- 服务定位容器
- 错误管理
- 事件管理
- 日志管理
- 网络基础库
- 安全工具
- 其他工具
安装
composer install scalpel/core
使用
工具
ListFilter
根据keys过滤数组元素
$listFilter->filter(sourceArray, keys)
示例
$array = [
[
'id' => 1, 'title' => "title", 'images' => [
['title' => "title", "src" => '1233', 'id' => 2],
['title' => "title", "src" => '1233', 'id' => 2],
]
],
[
'id' => 1, 'title' => "title", 'images' => [
['title' => "title", "src" => '1233', 'id' => 2],
['title' => "title", "src" => '1233', 'id' => 2],
]
]
];
$listFilter = new ListFilter();
$return = $listFilter->filter($array, [
'id|int', 'title@name',
['images', ['src', 'id'], true],
'images.id@imgId'
]);
var_dump($return);
keys语法: array[item, item], item格式支持
- 字符串字段
- 字符串.字符串
- 数组[item, keys]
待办事项
- 详细列出di的配置形式
- 处理Base::createObject()的参数或是丢弃此类,统一使用DI容器创建对象
Module::__constuct($id, $app);
admin => [
class => X
var => Value
]
Base::createObject(Array, [id, this])
# 一旦配置为数组, 导致丢弃第二参数导致错误
Base::createObject()
- 参数1为数组,丢弃第二个参数
- 参数1为字符串,使用第二个参数用于构造函数
DI::createObject
- 不为callback,丢弃第二个参数
- 为callback,使用第二个参数传递到callback