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

torann/promise

Torann/Promise provides a lightweight promise implementation for Laravel and PHP, letting you defer work and chain success or failure callbacks through a simple, fluent API. It helps organize asynchronous-style logic while keeping application code readable and easy to manage.

View on GitHub
Deep Wiki
Context7

torann/promise brings JavaScript-style promises to PHP and Laravel, giving asynchronous and deferred work a clean, chainable API. Rather than nesting callbacks, you compose then() and catch() handlers so success and failure paths stay flat, readable, and easy to test.

  • Chainable then() / catch() handlers for sequential flows
  • Deferred resolve/reject with value propagation down the chain
  • Consistent error handling that routes exceptions to the nearest catch
  • Lightweight, framework-agnostic core with Laravel-friendly integration
  • Composes cleanly with existing async and queued workloads
Frequently asked questions about Promise
What is torann/promise used for in a Laravel application?
It is a lightweight Promises/A+-style library that provides then() and catch() chaining, deferred resolve/reject, all() and race() helpers, a service provider and a facade. In a Laravel app its realistic role is organizing multi-step, synchronous request logic so success and failure paths stay flat instead of nesting try/catch blocks. It does not add real concurrency, because PHP-FPM executes a request on a single thread. Before adopting it, confirm what src/ actually contains: the repository metadata describes a Roles and Permissions package, which conflicts with the promise documentation.
How do I install torann/promise with Composer?
Run composer require torann/promise and then register the service provider and facade alias in config/app.php on older Laravel versions. The package targets a Laravel 5-era bootstrap, so on Laravel 8 and later the illuminate/* constraints will likely fail to resolve without a fork. Widening the constraint in an internal fork is the only honest fix; using --ignore-platform-reqs just moves the incompatibility from install time to production runtime.
Does torann/promise support Laravel 10 or Laravel 11?
Probably not out of the box. The package is built around config/app.php provider and alias registration plus Laravel 5-era illuminate/* constraints, while Laravel 11 moved service provider registration into bootstrap/providers.php and removed the traditional Kernel.php middleware setup. Composer resolution is likely to fail before you even reach those runtime changes. If you need it, plan for a maintained internal fork with updated constraints and registration.
Does torann/promise make my PHP code actually asynchronous?
No. PHP-FPM is synchronous and single-threaded, so then() callbacks execute inline rather than in the background. What you gain is readable control flow and a single error handler at the end of a chain, not parallelism. all() runs its items sequentially, and race() in a cooperative single-threaded runtime is deterministic, so it generally just returns the first element of the array rather than whichever finishes first.
How does catch() handle exceptions thrown inside a then() callback?
Exceptions thrown in a then() handler are routed to the nearest catch() in the chain, which is the main readability win over nested try/catch blocks. The common debugging trap is a chain with no catch at all, or a catch that returns null instead of rethrowing, which produces an empty page instead of a visible error. Always log inside catch or rethrow so failures surface during development and in production.
What is the difference between all() and race() in this package?
all() collects the results of every item in the chain and resolves with the full set of values, and because the runtime is single-threaded those items are processed sequentially rather than in parallel. race() resolves with the first settled result, but with no real concurrency the winner is effectively the first element in the array every time. Do not use race() expecting timing-based behavior; if you need genuine parallel I/O, use Laravel's Http::pool or queued jobs instead.
Is the Promise facade bound as a singleton, and does that cause state leaks?
That is one of the first things to verify in the service provider before using the package in production. If the provider registers a singleton, facade calls and app() resolution share one instance, so state can leak between chains, between requests in long-running workers, and between tests. Prefer a per-chain instance or a factory binding, and wrap usage behind your own interface so the binding is easy to change.
How do I test code that uses torann/promise?
Because callbacks run synchronously and eagerly within the request, ordinary PHPUnit assertions work fine and you do not need to wait on anything. The risk is shared facade state, so reset the container binding or avoid singletons between tests. The most testable approach is to depend on your own internal contract rather than on Torann\Promise directly, so promise chains can be swapped or mocked in isolation.
Is torann/promise actively maintained and safe to use in production?
The evidence points to abandonment: the README, package metadata and documented feature set disagree about what the library even does, and its framework constraints are Laravel 5-era. Treat it as a reference point for effort rather than a dependency candidate, and run a short spike to read composer.json and src/ before any design work. If you do adopt the capability, assign a named internal owner and host a fork in your own namespace.
What are the maintained alternatives to torann/promise in Laravel?
For concurrency, use queued jobs, Laravel's Http::pool, or Guzzle promises rather than a hand-rolled promise library; for true event-loop programming, ReactPHP or Amp. For short multi-step flows that may throw, plain try/catch is clearer, has no dependency, and will still compile years from now. If the source turns out to be the RBAC package after all, choose a currently maintained authorization package instead of a Laravel 5-era one.
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.
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core