puli/discovery
Composer 安装命令:
composer require puli/discovery
包简介
Publishes and discovers artifacts across Puli packages.
README 文档
README
Latest release: 1.0.0-beta9
PHP >= 5.3.9
The Puli Discovery Component supports binding of Puli resources to binding
types. Binding types can be defined with the addBindingType() method of the
EditableDiscovery interface:
use Puli\Discovery\Api\Type\BindingType; use Puli\Discovery\Binding\Initializer\ResourceBindingInitializer; use Puli\Discovery\InMemoryDiscovery; $discovery = new InMemoryDiscovery(array( // $repo is a Puli\Repository\Api\ResourceRepository instance new ResourceBindingInitializer($repo), )); $discovery->addBindingType(new BindingType('doctrine/xml-mapping'));
Resource Bindings
Resources in the repository can then be bound to the defined type by passing a
ResourceBinding to addBinding():
use Puli\Discovery\Binding\ResourceBinding; $discovery->addBinding(new ResourceBinding('/app/config/doctrine/*.xml', 'doctrine/xml-mapping'));
With findBindings(), you can later retrieve all the bindings for the type:
foreach ($discovery->findBindings('doctrine/xml-mapping') as $binding) { foreach ($binding->getResources() as $resource) { // do something... } }
The following Discovery implementations are currently supported:
Read the Resource Discovery guide in the Puli documentation to learn more about resource discovery.
Class Bindings
You can also bind classes to binding types. By convention, the common interface of all bound classes is used as binding type:
$discovery->addBindingType(new BindingType(Plugin::class));
Classes can be bound by adding ClassBinding instances:
use Puli\Discovery\Binding\ClassBinding; $discovery->addBinding(new ClassBinding(MyPlugin::class, Plugin::class));
As before, use findBindings() to find all bindings for a binding type:
foreach ($discovery->findBindings(Plugin::class) as $binding) { $pluginClass = $binding->getClassName(); $plugin = new $pluginClass(); // do something... }
Authors
Installation
Follow the Installation guide guide to install Puli in your project.
Documentation
Read the Puli Documentation to learn more about Puli.
Contribute
Contributions to Puli are always welcome!
- Report any bugs or issues you find on the issue tracker.
- You can grab the source code at Puli’s Git repository.
Support
If you are having problems, send a mail to bschussek@gmail.com or shout out to @webmozart on Twitter.
License
All contents of this package are licensed under the MIT license.
puli/discovery 适用场景与选型建议
puli/discovery 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 75.49k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2014 年 12 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 puli/discovery 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 puli/discovery 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 75.49k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 2
- 依赖项目数: 36
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2014-12-17