pionl/laravel-config-class-gate
Composer 安装命令:
composer require pionl/laravel-config-class-gate
包简介
Enables loading classes (or objects) via config files in Laravel
README 文档
README
You can provide overriding of your classes via config file (a list of classes defined by config key - like custom Eloquent model). With this you can work with expected model but add a posibility to allow extending of your base classes.
In default tries to load classes from the classes.php config file.
Example
Example config (classes.php in config folder):
<?php return [ "user" => App\\Models\\User::class ];
Call static method on class
$userGate = ClassGate::gate("user"); $users = $userGate->all() // will call User::all()
or shortcut
// will call User::all() $users = ClassGate::gate("user")->all();
Create instance
$userGate = ClassGate::gate("user"); $user = $userGate->newInstance();
or shortcut
$user = ClassGate::instance("user"); $user = $userGate->theClass();
Class string:
$userGate = ClassGate::gate("user");
or shortcut
$userClass = ClassGate::objectClass("user");
Settings
Own config path
You can provide your own file or "array" path to the config via ClassGate::setConfigPath("models.list") which will find classes in models file and list array entry.
Example config (models.php in config folder):
<?php return [ "othersKeys" : "...", "list" => [ "user" => App\\Models\\User::class ] ];
Todo
- Own provider with default config file (optional)
- Gate that will convert method call to config key and will create the correct
ClassGateinstance - A command that will create file with docs of supported models (will support typehint on ClassGate static methods)
ClassGate proposal
ClassGate::user()that will call ClassGate::gate("user")
pionl/laravel-config-class-gate 适用场景与选型建议
pionl/laravel-config-class-gate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 10 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 pionl/laravel-config-class-gate 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pionl/laravel-config-class-gate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-10-27