laravel/framework: CloudManager gains an isManagedQueue() helper
Contributed by jackbayliss
Part of the framework v13.36.0 release
PR #61568 adds a small but genuinely handy helper to the Laravel Cloud integration: isManagedQueue() on Illuminate\Foundation\Cloud\CloudManager, callable through the Cloud facade. It answers one question with a plain boolean — is this queue name one of the queues Laravel Cloud manages for this application? — so you can branch your queueing logic without reaching through the queue connection or maintaining your own macro. If you are upgrading from v12.70.0, this is a purely additive change on the 13.x line: nothing to migrate, no configuration to touch, and no existing method has changed behavior.
What Changed
CloudManager gains one new method:
public function isManagedQueue(string $queue): bool
It returns true only when two conditions hold: the application is configured to use Cloud managed queues (checked via the existing usesManagedQueues() method), and the given queue name appears in the list returned by the Cloud queue's managedQueues(). The comparison is strict, so you must pass the exact queue name, including any .fifo suffix.
The ordering of those two checks matters more than it might look. The existing Cloud::queue() method throws a RuntimeException when managed queues are not configured, which made any naive check awkward to write defensively. isManagedQueue() consults usesManagedQueues() first and short-circuits, so calling it on a local machine without Cloud queue configuration simply returns false instead of throwing. Tests were added in tests/Foundation/Cloud/CloudManagerTest.php covering both the positive and negative paths.
Why It Matters
Most non-trivial applications run more than one queue driver depending on the environment: a simple database or Redis driver locally, and Cloud managed queues in production — where FIFO queues and their .fifo naming are common. That forces conditional logic all over the place: should this job carry FIFO-specific flags? Should work be forwarded to a Cloud queue, or dispatched directly?
Before this change, answering "is this queue managed?" required knowing that Cloud::queue()->managedQueues() even existed, and wrapping it safely because of the exception behavior mentioned above. As the PR author notes, most people never realize that API is there, which is why they had macro'd their own version before deciding to upstream it. A dedicated, discoverable method on the manager means one obvious place to ask the question, and it reads clearly in application code.
Using It in Your App
The PR's own example shows the shape of the thing — check first, then act:
use Illuminate\Support\Facades\Cloud;
use Illuminate\Support\Facades\Queue;
if (Cloud::isManagedQueue('notifications.fifo')) {
Queue::forward('notifications', 'notifications.fifo', 'cloud');
}
Because the method lives on CloudManager, you can just as well inject the manager and keep your services framework-facade-free:
use Illuminate\Foundation\Cloud\CloudManager;
class DispatchReport
{
public function handle(CloudManager $cloud): void
{
$options = $cloud->isManagedQueue('reports.fifo')
? ['message-deduplication-id' => $this->dedupKey()]
: [];
ReportJob::dispatch($this->reportId, $options);
}
}
Both examples are safe to run in any environment: locally, isManagedQueue('reports.fifo') evaluates to false and your code falls through to the ordinary dispatch path.
Upgrade Impact
For anyone upgrading from v12.70.0, the impact is minimal:
- The change is additive. No existing method, configuration key, or interface has been altered, so there is no migration work beyond pulling the framework update on the 13.x line.
- If you previously registered your own
Cloud::isManagedQueuemacro (as the PR author did), the native method now takes precedence. PHP only routes calls to__call/macros when no real class method exists, so your macro becomes unreachable. Delete it and rely on the built-in method — the behavior should be equivalent, but double-check that your macro returned a strictin_arraymatch rather than a loose one, since the native implementation is strict. - No configuration changes are needed. When managed queues are not in use, the method short-circuits to
falsebefore resolving the queue connection, so it is safe to leave these checks in code paths that also run outside Cloud.
That's the entire surface area: one method, two conditions, a boolean result.
Takeaways
Cloud::isManagedQueue(string $queue): booltells you whether a queue name is one of your Laravel Cloud managed queues.- It is strict about names — include the
.fifosuffix when checking FIFO queues. - It returns
false(rather than throwing) on environments without managed queue configuration, so it is safe to use unconditionally. - If you had a similar macro on the
Cloudfacade, remove it; the native method now shadows it. - The change is purely additive on 13.x, so upgrading from v12.70.0 requires no code or config changes. }