Skip to content

Load Bref only on Craft Cloud, detected by CRAFT_CLOUD - #219

Merged
timkelty merged 3 commits into
5.xfrom
feature/lambda-only-bref
Dec 5, 2026
Merged

timkelty merged 3 commits into
5.xfrom
feature/lambda-only-bref

Conversation

@timkelty

@timkelty timkelty commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

bref/laravel-bridge auto-discovers in every project that requires craftcms/cloud. Its register() returns early off Lambda, but its boot() doesn't. So local dev and CI get:

  • a POST /signed-upload-url route
  • the ServeStaticAssets middleware
  • failed-job and job-logging listeners, and the queue:failed-* commands

It also pulls in bref/laravel-health-check, which auto-discovers too.

This PR:

  • Lists both packages under extra.laravel.dont-discover. Laravel merges that list from every installed package, so it applies in projects that require us.
  • Registers the bridge from CloudServiceProvider, on Craft Cloud only. The health check isn't registered anywhere: its only command, bref:health-check, is for bref.cloud's dashboard, which Craft Cloud doesn't use.
  • Detects Craft Cloud with CRAFT_CLOUD (0 and false count as off) instead of AWS_LAMBDA_RUNTIME_API.

laravel/octane and laravel/tinker, which the bridge requires, stay discoverable. They're general Laravel packages a project may use itself.

Important

cloud-api doesn't set CRAFT_CLOUD yet. Until it sets CRAFT_CLOUD=1 on every function, this package configures nothing on Craft Cloud.

Testbench doesn't read the root package's dont-discover, so testbench.yaml repeats the list for the workbench.[^1]

[^1]: Tests already turn off package discovery (Testbench's default ['*']), so the new test checks the provider's registration directly.

Evidence

New test, loads the Bref bridge only on Craft Cloud, and never its health check:

with CRAFT_CLOUD=1    → BrefServiceProvider registered, BrefHealthCheckServiceProvider not
without CRAFT_CLOUD   → neither registered

On 5.x, the "on Craft Cloud" case fails. With this change, composer ci passes: Pint, PHPStan, and 5 tests.

Package discovery in a simulated consumer project, where craftcms/cloud is an installed dependency:

                       BrefServiceProvider   BrefHealthCheck   CloudServiceProvider   Octane
without dont-discover  discovered            discovered        discovered             discovered
with dont-discover     not discovered        not discovered    discovered             discovered

Workbench route:list:

  • Before: POST signed-upload-url is listed.
  • After: it isn't.

Related issues

bref/laravel-bridge's boot() adds an upload route, middleware and job
listeners on every machine. Keep it and bref/laravel-health-check out
of package discovery, and register both from CloudServiceProvider on
Craft Cloud only.

Detect Craft Cloud with CRAFT_CLOUD instead of AWS_LAMBDA_RUNTIME_API.

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-794

@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-05T14:40:32.175990Z 092a954 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.

Its only command, bref:health-check, is for bref.cloud's dashboard,
which Craft Cloud doesn't use. It stays out of package discovery.

Amp-Thread-ID: https://ampcode.com/threads/T-5e08134f-736d-4bda-8b28-d21654023ef7
@timkelty
timkelty merged commit 1124995 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