zlikavac32/symfony-extras
Composer 安装命令:
composer require zlikavac32/symfony-extras
包简介
Various extra functionality for Symfony
README 文档
README
This repository adds a few extra functionality that I miss in the Symfony components. Functionality is currently only DIC and console related.
Table of contents
Introduction
Idea of this library is to use what you need. No dependency is explicitly required as no code is run by default. It provides few things, like various compiler passes to make a life a bit easier.
Compiler passes are all idempotent.
Installation
Recommended installation is through Composer.
composer require zlikavac32/symfony-extras
Usage
Different concepts exist in this library.
Runnable
symfony/console is a great package, but one can get into trouble when trying to decorate commands. This library defines \Zlikavac32\SymfonyExtras\Command\Runnable\Runnable interface which is then injected into \Zlikavac32\SymfonyExtras\Command\Runnable\RunnableCommand.
DIC compiler pass that automates this is provided in \Zlikavac32\SymfonyExtras\DependencyInjection\Compiler\ConsoleRunnablePass.
Read more about this concept in docs/runnable.md.
Dynamic service decorators and service linker
Symfony provides out of the box service decoration, but it can get messy when there is to much decoration involved. This library offers two compiler passes to tackle that. First is \Zlikavac32\SymfonyExtras\DependencyInjection\Compiler\DecoratorPass and the second is \Zlikavac32\SymfonyExtras\DependencyInjection\Compiler\ServiceLinkerPass.
Idea is to define template services that are decorators, and then tag services that need decoration. Since certain decorators need other services or arguments, service linker is used to link services through tags.
Read more about this concept in docs/dynamic-decorator.md and docs/linker.md.
Dynamic event dispatchers
Symfony provides \Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass to register event dispatchers. Compiler pass that can automate that process is provided in \Zlikavac32\SymfonyExtras\DependencyInjection\Compiler\EventDispatcherPass.
Read more about this concept in docs/dynamic-event-dispatcher.md.
Dynamic composite services
Certain services have composite nature in a sense that they require other services either in their constructor, or through method injection. Symfony provides solution in some degree through tagged service injection. This library provides compiler pass in \Zlikavac32\SymfonyExtras\DependencyInjection\Compiler\DynamicCompositePass that provides a bit more functionality.
Read more about this concept in docs/dynamic-composite.md.
One might say that here is to much magic involved, but if you understand how it all works, there is hardly any magic left.
buildMapOfTagsAndServiceIds()
Method findTaggedServiceIds() on the \Symfony\Component\DependencyInjection\ContainerBuilder finds tags in linear time depending on the number of services, so for M queries and N services, we have N * M operations.
Function buildMapOfTagsAndServiceIds() provided in this repo builds a map of tag names to the sets of service ids that are tagged with them. If we assume access to the hash map is in constant time, now we have N + M operations.
Do note that by not calling findTaggedServiceIds(), method \Symfony\Component\DependencyInjection\ContainerBuilder::findUnusedTags() will return more tags than it should. If you relay on that method, then this library is not for you.
Examples
Check examples folder for examples.
zlikavac32/symfony-extras 适用场景与选型建议
zlikavac32/symfony-extras 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 290 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 03 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「console」 「dic」 「compiler-pass」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 zlikavac32/symfony-extras 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 zlikavac32/symfony-extras 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 zlikavac32/symfony-extras 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This class provides you with an easy-to-use interface to progress bars.
A Laravel package to retrieve data from Google Search Console
Additional artisan commands for Laravel
The bundle for easy using json-rpc api on your project
A table generator class for the PHP CLI.
PHP 8.1-8.5 compatible fork of rdlowrey/auryn — a dependency injector for bootstrapping object-oriented PHP applications.
统计信息
- 总下载量: 290
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 9
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-21