Skip to content

Installation ​

Requirements: PHP 8.3+ and Laravel 12 or 13.

bash
composer require --dev chrisabner/cordon-modulith

Check what was detected ​

Cordon Modulith detects your module layout automatically:

bash
php artisan cordon:modules
text
Resolver: namespace
+---------+---------------------+---------------------+----------------+------+
| Module  | Namespace           | Path                | Depends on     | Open |
+---------+---------------------+---------------------+----------------+------+
| Billing | App\Modules\Billing | app/Modules/Billing | (not declared) | no   |
| Catalog | App\Modules\Catalog | app/Modules/Catalog | (not declared) | no   |
+---------+---------------------+---------------------+----------------+------+

With a plain app/Modules folder you see Resolver: namespace, as above. With nwidart/laravel-modules the same command prints Resolver: nwidart:

text
Resolver: nwidart
+----------+------------------+-----------------+----------------+------+
| Module   | Namespace        | Path            | Depends on     | Open |
+----------+------------------+-----------------+----------------+------+
| Billing  | Modules\Billing  | Modules/Billing | (not declared) | no   |
| Catalog  | Modules\Catalog  | Modules/Catalog | (not declared) | no   |
+----------+------------------+-----------------+----------------+------+
ResolverDetected whenModuleNamespace
nwidartModules/*/module.json existsModules/Blog → BlogModules\Blog (from config/modules.php)
internachiapp-modules/ existsapp-modules/billing → billingfrom the module's composer.json PSR-4 entry
namespacefallbackapp/Modules/Billing → BillingApp\Modules\Billing

If nothing is found, publish the config and set the resolver and its path (see Configuration).

Verify ​

bash
php artisan cordon:verify

It exits with 1 when there are violations, 0 otherwise and 2 on invalid options.

Publish the config (optional) ​

bash
php artisan vendor:publish --tag=cordon-config

Next: understand the public API of a module, or adopt it in an existing project if the first run reports many violations.

MIT licensed. A community project, not affiliated with or endorsed by Laravel or Spring.