jdomenechb / promised-entities
Fetch entities or value objects asynchronously by using promises
Requires
- php: ^7.1|^8
Requires (Dev)
- guzzlehttp/promises: ^1
- phpunit/phpunit: ^9.3
- symplify/easy-coding-standard-prefixed: ^8.3
- vimeo/psalm: ^3.16
This package is auto-updated.
Last update: 2025-03-01 00:32:56 UTC
README
Have you ever wondered how you can integrate asynchronous PHP features with code structures like Domain Driven Design?
This library, among other uses, will allow you to use promises to instantiate objects asynchronously without having to compromise your code structure or use third-party classes in contract definition.
What does this library try to solve?
Installation
Run in the root of your project:
composer require jdomenechb/promised-entities
Usage
// ... $promisedEntityFactory = PromisedEntityFactory::create(new GuzzleMethodBodyGenerator()); $promisedEntityFactory->build(YourEntity::class, $promise);
$promise
is the Promise instance which resolution will return the loaded entity. It should match the given
MethodBodyGenerator
class which will know how to deal with it.
An example of implementation using this library can be seen in the test src files.