tax16/tools
最新稳定版本:1.0.2
Composer 安装命令:
composer require tax16/tools
包简介
tools bundle
README 文档
README
A Symfony bundle compatible with PHP 8.2+ and symfony 6+
🚀 Installation
Add the bundle via Composer
Run the following command in your terminal:
composer require tax16/tools
⚙️ Features
- Retry:
- Retry logic with customizable delay
- Configurable max attempts
- Easy integration with Symfony or standalone PHP
⚙️ How It Works — Retry via Dynamic Proxy
This bundle uses ocramius/proxy-manager to dynamically intercept method calls and apply automatic retry logic based on PHP attributes.
🧠 Behind the Scenes
A dedicated class, RetryProxyFactory, creates a dynamic proxy around any service. This proxy:
- Intercepts public methods annotated with the
#[Retry]attribute - Retries the execution when an exception is thrown
- Logs each failed attempt using
Psr\Log\LoggerInterface - Honors the parameters
attempts(number of retries) anddelay(delay between attempts in seconds)
This behavior is completely transparent to your application code.
🔁 Example: Using the #[Retry] Attribute
use Tax16\ToolsBundle\Core\Domain\Retry\Attribut\Retry; class ExternalApiClient { #[Retry(attempts: 3, delay: 1)] public function fetchData(): void { // This method will be retried up to 3 times with a 1s delay on failure } }
🤝 Contributing
The application is designed in hexagonal architecture:
To contribute to the SystemCheckBundle, follow these steps:
-
Clone the repository:
git clone https://github.com/tax16/ToolsBundle
-
Install dependencies:
make install
-
Run GrumPHP for code quality checks:
make grumphp
-
Run tests:
make phpunit
Happy coding! 🎉
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-17
