New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

nwidart/larch

Architecture rules for Laravel apps that see facades, the container, events and routes. A Pest plugin.
69 2
Install
composer require nwidart/larch
Latest Version:v0.1.0
PHP:^8.3
License:MIT
Last Updated:Nov 25, 2026
Links: GitHub  ·  Packagist
Maintainer: nWidart

Larch

CI Latest Version on Packagist Total Downloads PHP Version License

Larch: architecture rules for Laravel apps, as a Pest plugin

Architecture rules for Laravel apps, as a Pest plugin. Larch checks which module uses which, and prints every link that breaks a rule with the file and line it comes from.

Larch reads links from the code, and from the booted app: facades, container keys, event listeners and dispatched jobs. Import-based tools cannot see those.

Larch is in early development.

Install

composer require nwidart/larch --dev

Larch needs PHP 8.3 or later and Pest 4.3 or later.

Example

Name the modules once, in tests/Pest.php:

use function Nwidart\Larch\larch;

larch()
    ->modules('Modules\*')
    ->publicApi('Contracts', 'Events');

Then write rules:

use Nwidart\Larch\Edge;

use function Nwidart\Larch\module;
use function Nwidart\Larch\modules;

arch('billing uses only shared, and the public API of catalog')
    ->expect(module('Billing'))
    ->toOnlyDependOn(module('Shared'), module('Catalog')->publicApi())
    ->via(Edge::all());

arch('no module is in a cycle')
    ->expect(modules())
    ->toHaveNoCycles();

A failure names each link that breaks the rule:

  Modules/Billing/app/Actions/ChargeOrder.php:16
    Modules\Billing\Actions\ChargeOrder uses Modules\Catalog\Pricing\PriceEngine
    It is internal to Catalog. The public API of a module is: Contracts, Events.

Documentation

Read the full documentation at nwidart.github.io/larch:

License

MIT. See LICENSE.md.

Related Packages

ianrodrigues/pest-plugin-code-quality

Method-level and class-level maintainability limits (complexity, body lines, par...

510 4
zangles/laravel-mda

Generadores y reglas de arquitectura para Model Domain Architecture (MDA) en Lar...

2 0
pestphp/pest-plugin-arch

The Arch plugin for Pest PHP.

96,607,913 44
offset-smoker/pest-ratchets

Architecture ratchets for Pest: rules that find offenders with a real PHP parser...

2 0

Version History

Version Released PHP License
v0.1.0 ^8.3 MIT