scalpel / core
The core components of my PHP applications
dev-master
2019-04-24 06:34 UTC
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2025-02-24 22:36:49 UTC
README
一些基础php组件
- 配置
- 缓存
- 动态方法管理
- 调试工具
- 服务定位容器
- 错误管理
- 事件管理
- 日志管理
- 网络基础库
- 安全工具
- 其它工具
安装
composer install scalpel/core
Usage
tool
ListFilter
根据keys过滤数组元素
$listFilter->filter(sourceArray, keys)
example
$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格式支持:
- string 字段
- string.string
- array[item, keys]
Todo
- 详细列出 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