Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Promise Laravel Package

php-standard-library/promise

Lightweight Promise implementation for PHP with a simple, standards-inspired API. Create, resolve, reject, and chain async-style operations, handle errors, and compose results with familiar then/catch patterns—ideal for libraries that need non-blocking workflows.

View on GitHub
Deep Wiki
Context7

Promise interface for deferred computations - resolved or rejected

Frequently asked questions about Promise
What is php-standard-library/promise used for in Laravel?
It provides a lightweight Promise interface for deferred computations that are resolved or rejected. In Laravel you can use it to compose async-style workflows such as chaining API client calls, orchestrating queue-dispatched jobs, or sequencing event-driven logic without adding a full event loop. It is best suited to libraries, SDKs, or bounded service layers where you need then/catch composability.
How do I install php-standard-library/promise with Composer?
Install it via Composer using composer require php-standard-library/promise. The package has minimal dependencies and does not require ReactPHP, Amp, or another event loop. After installation, import the Promise classes in your service or library code and start composing resolved, rejected, or deferred operations.
Does php-standard-library/promise support Laravel 10 and Laravel 11?
The package assumes PHP 8.1 or newer, which aligns with modern Laravel LTS releases. It is a framework-agnostic Promise implementation, so it can be used in Laravel 10, Laravel 11, and other Laravel versions that run on supported PHP versions. Check the package’s Composer constraints for the exact Laravel compatibility matrix before upgrading.
How does php-standard-library/promise integrate with Laravel queues and jobs?
Promises do not replace Laravel’s queue system, but they can wrap dispatch calls or Bus jobs to coordinate dependent work. For example, you can resolve a Promise after dispatching a job and chain post-processing with then, or compose multiple job dispatches with combinators such as Promise::all. You still need queue workers to execute the underlying jobs.
Can I use php-standard-library/promise for parallel HTTP requests in Laravel?
Yes, you can adapt Guzzle or another HTTP client so its send operation returns a Promise, then compose multiple requests with Promise::all or Promise::race. This is useful for API integrations where you want to fan out requests and combine results. The package itself does not provide an event loop, so actual concurrency depends on how the HTTP client and your execution strategy resolve the promises.
How should I handle errors and unhandled rejections with php-standard-library/promise?
Use catch callbacks on Promise chains to handle rejected promises, similar to familiar then/catch patterns. Because PHP has no native async/await, you should add a global or service-level rejection handler so unhandled rejections are logged or reported, for example through Laravel’s exception handler or Sentry. Critical flows should include retry or fallback logic rather than relying only on catch.
Is php-standard-library/promise suitable for production Laravel applications?
It can be suitable for bounded contexts such as API clients, background job orchestration, and libraries that need composable async workflows. Be careful to avoid blocking calls inside then callbacks, and plan how promises are resolved through queues, callbacks, or a custom loop. For high-throughput batch resolution, benchmark overhead and consider batching or worker pools.
How do I test php-standard-library/promise code in PHPUnit?
You can stub or mock Promise resolutions with tools like Mockery and assert that then and catch callbacks receive the expected values. Keep async flows small and inject Promise-returning dependencies so tests can resolve or reject them deterministically. For Laravel feature tests, pair this with Queue::fake or Bus::fake when promises wrap dispatched jobs.
What are alternatives to php-standard-library/promise for async PHP in Laravel?
Alternatives include full async frameworks such as ReactPHP and Amp, Laravel’s built-in Bus and Queue system for background work, and PHP 8.1+ fibers for lower-level concurrency. This package is a lighter option when you want then/catch composability without adopting an event loop. Choose based on whether you need orchestration only or actual non-blocking execution.
How is php-standard-library/promise maintained and documented?
It is part of the PHP Standard Library project, with documentation at php-standard-library.dev and issues and pull requests managed on GitHub. The package is intentionally lightweight and framework-agnostic, so maintenance focuses on the Promise contract and combinators rather than Laravel-specific integrations. Review the repository releases and documentation for the latest supported PHP versions and API changes.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator