Download the PHP package chrisabner/cordon-modulith without Composer

On this page you can find all versions of the php package chrisabner/cordon-modulith. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cordon-modulith

Cordon Modulith

Tests Latest version Downloads

Cordon off your modules. Verifiable boundaries between the modules of a Laravel application, checked in CI.

Status: 0.2 (alpha). The public API may change before 1.0. Documentation

Modular monoliths in Laravel usually rely on nwidart/laravel-modules, InterNACHI/modular or a hand-made app/Modules folder. All of them organise code, but none of them stops the Billing module from reaching into Catalog's models. Six months later the "modules" are just folders.

Cordon Modulith reads your code statically, builds the dependency graph between modules and fails the build when a module:

It also keeps AI coding agents honest: Cordon Modulith ships Laravel Boost resources that teach agents to go through a module's public API and to fix the violations cordon:verify reports.

It is inspired by Spring Modulith and Shopify's Packwerk, adapted to Laravel conventions.

Tried on real apps: on Bagisto (42 packages, 2,000 files) Cordon found 158 internal accesses and 30 packages tangled in dependency cycles, in 6 seconds and with no false positives. See the case studies.

Requirements

Installation

Cordon Modulith detects your module layout automatically. Check what it found:

Then verify the boundaries:

Optionally publish the config file:

Adopting Cordon Modulith in an existing project

Existing codebases usually start with many violations. Record them in a baseline so the build only fails on new ones, then burn the baseline down over time:

Commit cordon-baseline.json. Entries are keyed by rule, file and target class (not line numbers), so unrelated edits don't invalidate them.

The public API of a module

Other modules may only use classes that belong to a module's public API. A class is public when, in order of precedence:

  1. it is marked #[Cordon\Attributes\Internal] → internal, always;
  2. it is marked #[Cordon\Attributes\PublicApi] → public;
  3. its module is configured as open → public (handy for a shared kernel);
  4. it lives under one of the public namespaces, relative to the module: Contracts, Events, Data, Enums, Exceptions by default, plus the module's own public list → public;
  5. otherwise → internal.

public_namespaces match at any depth relative to the module: an entry counts when it appears as a whole segment (or a contiguous run of segments, such as Http\Resources) in the class's namespace. Modules\Billing\Contracts\Gateway, Modules\Billing\Invoices\Enums\Status and Modules\Billing\Invoices\Events\Sub\InvoicePaid are public; Modules\Billing\Invoices\MyEnums\Status and Modules\Billing\EnumsHelper\Foo are not (whole segments only). The module's own public list is different: its entries stay anchored at the module root, e.g. Services\BillingService. If a nested Enums or Events class must stay internal, mark it with #[Internal].

DTOs is not in the defaults (only Data). If you use it, add it to public_namespaces, e.g. ['Contracts', 'Events', 'Data', 'DTOs', 'Enums', 'Exceptions'] (setting the option replaces the default list).

The recommended way for modules to talk to each other is through contracts (interfaces bound in the module's service provider), events and data objects.

Configuration

depends_on is opt-in per module: modules without it are not checked by undeclared_dependency.

Module layouts

Resolver Detected when Module Namespace
nwidart Modules/*/module.json exists Modules/Blog → Blog Modules\Blog (from config/modules.php)
internachi app-modules/ exists app-modules/billing → billing from the module's composer.json PSR-4 entry
namespace fallback app/Modules/Billing → Billing App\Modules\Billing

Paths and namespaces can be overridden under resolvers in the config file.

Rules

Rule Reports
internal_access A module using a class that is not part of another module's public API. One report per file and target class.
undeclared_dependency A module with depends_on using a module that is not listed. One report per file and target module.
cycles Modules that depend on each other in a cycle. One report per dependency inside the cycle, with the shortest cycle it closes.

You can add your own rules: list classes implementing Cordon\Contracts\Rule under rules in the config. See docs/custom-rules.md.

Continuous integration

Use the reusable GitHub Action to get annotations on pull requests:

Or add php artisan cordon:verify --format=github to an existing job. --format=json prints a machine readable report. The command exits with 1 when there are violations or no modules are found (--allow-empty passes while a project has none yet), 0 otherwise and 2 on invalid options. See docs/ci.md for the action inputs and a job per module.

One module at a time

--module (repeatable) reports only the violations a module causes and the dependency cycles it takes part in.

Pest

Check boundaries from your test suite with the toRespectBoundaries() expectation. It needs a booted application, so use it in tests that extend your Tests\TestCase. A fresh Laravel app with Pest doesn't bind it yet: run composer require --dev pestphp/pest pestphp/pest-plugin-laravel -W (-W lets Composer change the PHPUnit version the app has locked) and ./vendor/bin/pest --init, or make sure tests/Pest.php contains pest()->extend(Tests\TestCase::class)->in('Feature');.

The analysis runs once per test process and honours the baseline, like cordon:verify. The each form stops at the first failing module (Pest behaviour).

PHPStan

Cordon Modulith ships a PHPStan rule that reports internal_access in your editor. A fresh Laravel app doesn't ship PHPStan, so install it first with composer require --dev phpstan/phpstan (Larastan already brings it). With phpstan/extension-installer the rule is enabled automatically: composer config allow-plugins.phpstan/extension-installer true && composer require --dev phpstan/extension-installer. Otherwise include the extension by hand in a minimal phpstan.neon:

List the folders your modules live in: app for app/Modules, Modules for nwidart/laravel-modules, app-modules for InterNACHI/modular. PHPStan stops if a listed path doesn't exist.

The rule reads config/cordon.php without booting Laravel, so keep that file a plain array. Set parameters.cordon.basePath if PHPStan does not run from the project root. Dependency cycles and depends_on are only checked by cordon:verify.

Living documentation

Generate Markdown documentation of the real architecture, straight from the code:

The output folder is created if it doesn't exist. GitHub renders the Mermaid diagrams, and the output is deterministic, so commit it and review architecture changes in pull requests.

AI coding agents

Cordon Modulith ships Laravel Boost resources that Boost picks up when you run php artisan boost:install:

How it works

Cordon Modulith parses every PHP file inside your modules with nikic/php-parser. Your code is never loaded or executed, so it works on code that doesn't boot and on classes that don't exist yet. It records every class reference (new, static calls, type declarations, extends/implements, traits, attributes, instanceof, catch...) and maps each one to its module by namespace. Import statements alone, function calls and constants don't count. Speed is around 1 ms per file on a typical CI runner (about a second for 1,000 files, Linux, no Xdebug). Run with Xdebug off (XDEBUG_MODE=off php artisan cordon:verify): Xdebug makes it 3-4x slower, and the first run on Windows can be slower because of cold file reads and antivirus scanning. See docs/adr for the design decisions behind it.

Known limitations in 0.1: docblock-only types (@var, generics), string class names ('App\\Foo', app('...')) and dynamic references are not detected. Code outside modules (for example app/Http) is not analysed. When Cordon runs standalone (the PHPStan rule), project config files are evaluated without booting Laravel. If one can't be evaluated, the rule reports a cordon.configuration error and falls back to defaults; see PHPStan.

Roadmap

What's next:

Ideas and bugs are welcome in GitHub issues.

Contributing

See AGENTS.md first.

License

MIT. See LICENSE.md.

Cordon Modulith is a community project and is not affiliated with or endorsed by Laravel, or by the Spring team, VMware or Broadcom (Spring Modulith inspired the name and the approach).


All versions of cordon-modulith with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/console Version ^12.0|^13.0
illuminate/container Version ^12.0|^13.0
illuminate/contracts Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
nikic/php-parser Version ^5.3
vlucas/phpdotenv Version ^5.6.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package chrisabner/cordon-modulith contains the following files

Loading the files please wait ...