djmattyg007/autocodeloader
Composer 安装命令:
composer require djmattyg007/autocodeloader
包简介
Generate utility classes such as proxies and factories automatically.
README 文档
README
AutoCodeLoader
This project will automatically generate standardised factories, proxies and
setter traits, to avoid you having to duplicate this boilerplate constantly.
It also provides a reliable means for cache-busting autogenerated files and
the ability to pre-generate all files.
AutoCodeLoader will automatically generate the following kinds of files:
- Factories - \MyNamespace\MyPackage\MyClassFactory
- Proxies - \MyNamespace\MyPackage\MyClassProxy, \MyNamespace\MyPackage\MyInterfaceProxy
- Shared Proxies - \MyNamespace\MyPackage\MyClassSharedProxy, \MyNamespace\MyPackage\MyInterfaceSharedProxy
- Setter Traits - \MyNamespace\MyPackage\NeedsMyClassFactoryTrait
Some notes:
- Shared proxies will retrieve services from the dependency injection
container, meaning all usages of the same shared proxy will deal with the
same instance of the requested service.
- It is possible to autogenerate setter traits for autogenerated factories and
proxies, as the above example implies.
To use this in production systems, you're going to want to pre-generate all
files. Pre-generating all files gives you the ability to exclude this package
entirely from your deployments, giving you the peace of mind that no
autogeneration is occurring in production systems. To be able to use the files
generated by this package when it isn't present, you simply need to bootstrap
the composer autoloader like so:
$composer = require("/path/to/vendor/autoload.php");
if (class_exists("\\MattyG\\AutoCodeLoader\\Autoloader") === true) {
\MattyG\AutoCodeLoader\Autoloader::registerAutoloader("/path/to/generated/files");
} else {
$composer->addPsr4("", "/path/to/generated/files");
}
This package makes quite a few assumptions at the moment:
- It will only generate proxies and factories designed to work with the Aura.Di
dependency injection container. Support for other dependency injection
containers is most welcome, but I do not have time to build this support at
the moment.
- There is no magic with the setter traits - it relies on you using them,
and/or configuring them for use within your dependency injection container.
In conclusion:
I built this because I was unable to find something simple that wasn't weighed
down by many dependencies, and that had first-class support for PHP7. Nothing
else was as simple as what I needed and was able to work with the Aura.Di
container, which is my personal preference.
You should not depend on this library if you are writing a library yourself!
That would be like depending on Illuminate\Support, which is a bad idea. This
library is designed solely for use within applications where a large amount
of code is being written. Do not burden your users with unnecessary
dependencies!
This software is released into the public domain without any warranty.
djmattyg007/autocodeloader 适用场景与选型建议
djmattyg007/autocodeloader 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 05 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 djmattyg007/autocodeloader 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 djmattyg007/autocodeloader 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 18
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unlicense
- 更新时间: 2016-05-07