tax16 / tools
tools bundle
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=8.2
- ext-ctype: *
- ext-iconv: *
- friendsofphp/proxy-manager-lts: ^1.0
- laminas/laminas-code: ^4.0
- symfony/console: 7.2.*
- symfony/dotenv: 7.2.*
- symfony/flex: ^2
- symfony/framework-bundle: 7.2.*
- symfony/runtime: 7.2.*
- symfony/yaml: 7.2.*
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! 🎉