tourze / async-contracts
异步
Installs: 7 994
Dependents: 19
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/tourze/async-contracts
Requires
- php: ^8.1
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-10-31 05:09:15 UTC
README
A simple contract package that provides interfaces for asynchronous messaging in PHP applications. This package defines the basic contract for async message handling without any implementation details.
Installation
composer require tourze/async-contracts
Quick Start
This package provides a base interface for async message handling:
<?php use Tourze\AsyncContracts\AsyncMessageInterface; // Implement the interface in your async message classes class MyAsyncMessage implements AsyncMessageInterface { // Your implementation here }
Usage
The AsyncMessageInterface serves as a marker interface for async message objects. It currently contains no methods, allowing maximum flexibility for implementers to define their own message structure.
<?php namespace App\Messages; use Tourze\AsyncContracts\AsyncMessageInterface; class UserRegistrationMessage implements AsyncMessageInterface { public function __construct( private string $userId, private string $email ) {} public function getUserId(): string { return $this->userId; } public function getEmail(): string { return $this->email; } }
Requirements
- PHP 8.1 or higher
Testing
./vendor/bin/phpunit packages/async-contracts/tests
License
This package is open-source software licensed under the MIT license.