tax16/tools

tools bundle

Installs: 5

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

1.0.2 2025-04-19 18:04 UTC

This package is auto-updated.

Last update: 2025-04-19 20:12:50 UTC


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) and delay (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:

Network design

To contribute to the SystemCheckBundle, follow these steps:

  1. Clone the repository:

    git clone https://github.com/tax16/ToolsBundle
  2. Install dependencies:

    make install
  3. Run GrumPHP for code quality checks:

    make grumphp
  4. Run tests:

    make phpunit

Happy coding! 🎉