Download the PHP package friendsofhyperf/support without Composer
On this page you can find all versions of the php package friendsofhyperf/support. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download friendsofhyperf/support
More information about friendsofhyperf/support
Files in friendsofhyperf/support
Package support
Short Description Another support component for Hyperf.
License MIT
Informations about the package support
Support
中文说明
A comprehensive support component for Hyperf providing essential utilities, helpers, and base classes.
Features
- 🎯 Fluent Dispatch API - Elegant job dispatch with support for async queue, AMQP, and Kafka
- 🔄 Closure Jobs - Execute closures as background jobs with dependency injection
- 🛠️ Helper Functions - Collection of useful helper functions
- 📦 Bus System - Pending dispatch classes for various message systems
- 🧩 Traits & Utilities - Reusable traits and utility classes
- ⏱️ Backoff Strategies - Multiple retry backoff implementations for retry mechanisms
Installation
Usage
Dispatch Helper Function
The dispatch() helper function provides a fluent API for dispatching jobs to different systems:
Async Queue (Closure Jobs)
AMQP Producer Messages
Kafka Producer Messages
CallQueuedClosure
The CallQueuedClosure class allows you to execute closures as async queue jobs:
Pending Dispatch Classes
PendingAsyncQueueDispatch
Fluent API for async queue job dispatch:
PendingAmqpProducerMessageDispatch
Fluent API for AMQP message dispatch:
PendingKafkaProducerMessageDispatch
Fluent API for Kafka message dispatch:
Conditional Execution
All pending dispatch classes support conditional execution:
API Reference
dispatch($job)
Creates a pending dispatch instance based on the job type:
Closure→PendingAsyncQueueDispatchwithCallQueuedClosureProducerMessageInterface→PendingAmqpProducerMessageDispatchProduceMessage→PendingKafkaProducerMessageDispatch- Other objects →
PendingAsyncQueueDispatch
PendingAsyncQueueDispatch Methods
onConnection(string $connection): static- Set queue connectiondelay(int $delay): static- Delay job execution (seconds)setMaxAttempts(int $attempts): static- Set max retry attemptswhen(mixed $condition, callable $callback): static- Conditional executionunless(mixed $condition, callable $callback): static- Inverse conditional execution
PendingAmqpProducerMessageDispatch Methods
setPool(string $pool): static- Set AMQP pool namesetExchange(string $exchange): static- Set exchange namesetRoutingKey(array|string $routingKey): static- Set routing key(s)setTimeout(int $timeout): static- Set timeout (seconds)setConfirm(bool $confirm): static- Enable/disable confirm modewhen(mixed $condition, callable $callback): static- Conditional executionunless(mixed $condition, callable $callback): static- Inverse conditional execution
PendingKafkaProducerMessageDispatch Methods
setPool(string $pool): static- Set Kafka pool namewhen(mixed $condition, callable $callback): static- Conditional executionunless(mixed $condition, callable $callback): static- Inverse conditional execution
CallQueuedClosure
create(Closure $closure): static- Create a new closure jobsetMaxAttempts(int $attempts): void- Set max retry attemptshandle(): mixed- Execute the closure (called by queue worker)
Backoff Strategies
The component provides various backoff strategies for retry mechanisms:
ArrayBackoff
Use custom delay intervals defined in an array:
Available Backoff Implementations
- ArrayBackoff - Custom intervals from an array
- FixedBackoff - Constant delay between retries
- LinearBackoff - Linear growth with configurable step
- ExponentialBackoff - Exponential growth with optional jitter
- FibonacciBackoff - Fibonacci sequence-based delays
- PoissonBackoff - Statistical distribution-based delays
- DecorrelatedJitterBackoff - Decorrelated jitter for better spreading
Common Backoff Interface
All backoff implementations implement BackoffInterface:
Contact
- Gmail
License
MIT
All versions of support with dependencies
hyperf/context Version ~3.2.0
hyperf/di Version ~3.2.0
hyperf/macroable Version ~3.2.0
hyperf/pipeline Version ~3.2.0
hyperf/stringable Version ~3.2.0
hyperf/support Version ~3.2.0
hyperf/tappable Version ~3.2.0
laravel/serializable-closure Version ^1.0 || ^2.0
nesbot/carbon Version ^2.0 || ^3.0
symfony/polyfill-php85 Version ^1.33