Skip to content

Warn when the detected modules are the layers of a Laravel app - #34

Merged
ChrisAbner merged 1 commit into
mainfrom
feat/layered-app-hint
Nov 5, 2026
Merged

ChrisAbner merged 1 commit into
mainfrom
feat/layered-app-hint

Conversation

@ChrisAbner

Copy link
Copy Markdown
Owner

The most common app that will try Cordon, especially after the announcement, is split by layer (app/Http, app/Models, app/Services...) rather than by feature. Pointed at app/, Cordon reports almost every reference as internal_access, plus one large cycle. That reads as "Cordon is broken" instead of "this app is layered". comparison.md already says layered rules are Deptrac's job, but only after installing. Closes #22.

cordon:modules now warns when at least two of the detected modules are named like standard Laravel layers (Http, Models, Providers, Services, Console, Jobs...). The warning links to a new "Is Cordon for my project?" section at the top of the installation guide, which points layered apps to Deptrac or Pest arch() and tells teams moving to modules where to point Cordon. The threshold is two because a single module can legitimately be called like a layer, a Notifications module say. The check lives in Cordon\Module\LayeredLayout, a pure function over the module names, so vendor/bin/cordon modules gets it too. The exit code doesn't change: it's a hint, not a failure.

Verification.

Case Before After
vendor/bin/cordon modules on a layered app (Http, Models, Providers, Services) table only table, then the warning with the docs link; exit 0
cordon:modules on the feature-module fixture table only table only
Modules Billing, Catalog, Notifications no warning (one layer name)
Docs build id="is-cordon-for-my-project" present, link to the comparison resolves

New tests/Fixtures/layered-app, 3 unit tests for LayeredLayout and 2 command tests. composer check passes (159 tests).

Not covered: cordon:verify doesn't show the hint; it's the command people run after cordon:modules in the installation guide. The list of layer names is a judgement call; an app with unusual layer names won't get the hint.

The most common app that tries Cordon is split by layer (app/Http,
app/Models, app/Services...). Pointed at app/, Cordon reports almost
every reference as internal_access plus one large cycle, which reads as
"Cordon is broken" rather than "this app is layered".

cordon:modules (and vendor/bin/cordon modules) now warns when at least
two modules are named like standard Laravel layers, and links to a new
"Is Cordon for my project?" section at the top of the installation
guide, which points layered apps to Deptrac or Pest arch(). One module
named like a layer, such as Notifications, is not enough.

Closes #22
@ChrisAbner ChrisAbner added this to the 0.4.0 milestone Nov 5, 2026
@ChrisAbner
ChrisAbner merged commit 3ad9130 into main Nov 5, 2026
9 checks passed
@ChrisAbner
ChrisAbner deleted the feat/layered-app-hint branch November 5, 2026 18:50
@ChrisAbner ChrisAbner mentioned this pull request Nov 5, 2026
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.

Say before installing whether Cordon fits the project

1 participant