Skip to content

Run Craft Cloud's functions as Bref does - #220

Merged
timkelty merged 6 commits into
5.xfrom
feature/bref-functions
Dec 5, 2026
Merged

timkelty merged 6 commits into
5.xfrom
feature/bref-functions

Conversation

@timkelty

@timkelty timkelty commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Brings back what Craft Cloud's Lambda functions run, written from Bref's docs rather than ported from 3.x. Bref and bref/laravel-bridge already ship every handler, so the package adds no handler code.

Function BREF_RUNTIME Handler (CMD)
Web fpm public/index.php
Queue worker function Bref\LaravelBridge\Queue\QueueHandler
Console console artisan, with the command as the event

All functions also need QUEUE_CONNECTION=sqs and SQS_QUEUE, as in Bref's Laravel queues docs.

On Craft Cloud, the provider also turns off Craft settings that don't apply to a read-only image that Craft Cloud deploys and backs up:

  • allowUpdates
  • ideHelperEnabled. Saving a field layout writes PHPDoc files into vendor/_craft.
  • backups.command, backups.restoreCommand, backups.onUpdate
  • queue.runAutomatically. Otherwise control panel requests call Queue::size() against SQS and run queue:work --once in the web function.
  • project config's writeYamlAutomatically. Craft 5's CRAFT_EPHEMERAL did this, and Craft 6 doesn't read it.

They're set with callAfterResolving(), so they win over the project's config/craft/general.php and over deprecated CRAFT_* environment overrides.

Important

Stacked on #219, which registers the bridge on Craft Cloud. QueueHandler's $connection binding comes from the bridge's provider, so the worker needs CRAFT_CLOUD=1.

Evidence

New test, runs Craft's queued jobs with Bref's QueueHandler on Craft Cloud[^1]:

dispatch(RecordingJob('hello'))   → SQS SendMessage to SQS_QUEUE
QueueHandler->handleSqs(message)  → job handled, SQS DeleteMessage
  • Before (off Craft Cloud): Unresolvable dependency resolving [... string $connection] in class QueueHandler
  • After: passes

overrides the cache, logs, sessions and Craft settings on Craft Cloud fails without the new settings and passes with them. composer ci passes: Pint, PHPStan, 6 tests.

[^1]: The AWS client is stubbed with Aws\MockHandler. QUEUE_CONNECTION and SQS_QUEUE come from the environment, as on Lambda.

Related issues

…ttings

Craft Cloud's functions use Bref's own handlers: PHP-FPM for the web,
bref/laravel-bridge's QueueHandler for the SQS worker, and the console
runtime with artisan. The README documents them as the contract with
infrastructure, and a test runs a Craft job through QueueHandler.

On Craft Cloud, turn off Craft settings that don't apply to a read-only
image that Craft Cloud deploys and backs up: allowUpdates, backups,
queue.runAutomatically and writeYamlAutomatically.

Amp-Thread-ID: https://ampcode.com/threads/T-5e08134f-736d-4bda-8b28-d21654023ef7
@linear-code

linear-code Bot commented Dec 5, 2026

Copy link
Copy Markdown

CLOUD-795

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-05T15:18:15.455133Z 2e1e464 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Saving a field layout writes PHPDoc files into vendor/_craft, which fails
on the read-only image.

Amp-Thread-ID: https://ampcode.com/threads/T-5e08134f-736d-4bda-8b28-d21654023ef7
Craft defaults ideHelperEnabled to APP_DEBUG. Locally the workbench's
skeleton .env set it to true; CI has no .env, so the off-Cloud baseline
was false there.

Amp-Thread-ID: https://ampcode.com/threads/T-5e08134f-736d-4bda-8b28-d21654023ef7
@timkelty
timkelty changed the base branch from feature/lambda-only-bref to 5.x December 5, 2026 15:27
@timkelty
timkelty merged commit 1046399 into 5.x Dec 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant