Define your modules
Configure Larch once, in tests/Pest.php. Every rule of the run uses this configuration.
Modules under one namespace
Section titled “Modules under one namespace”When each module is a namespace under one parent, give the parent with \*:
use function Nwidart\Larch\larch;
larch()->modules('App\Domain\*');Each namespace directly under App\Domain is a module, named by that namespace: App\Domain\Billing is Billing.
With nwidart/laravel-modules
Section titled “With nwidart/laravel-modules”With nwidart/laravel-modules installed, call modules() with no argument. It uses Modules\*:
larch()->modules();nwidart/laravel-modules defines a global module() helper. Import Larch’s functions with use function
in each test file, so PHP does not call the global one:
use function Nwidart\Larch\module;use function Nwidart\Larch\modules;Modules in different places
Section titled “Modules in different places”When modules do not share a parent namespace, name each one:
larch()->modules([ 'Billing' => 'App\Billing', 'Catalog' => 'App\Catalog', 'Shared' => 'Support\Shared',]);Set the public API
Section titled “Set the public API”The public API is the part of a module other modules may use. List its namespaces, relative to each module:
larch() ->modules('Modules\*') ->publicApi('Contracts', 'Events', 'Data');Contracts means Modules\Billing\Contracts for Billing, and Modules\Catalog\Contracts for Catalog.
Without publicApi(), the public API is Contracts and Events.
Choose the folders to read
Section titled “Choose the folders to read”Larch reads every PSR-4 folder of the project outside vendor. To read only some folders:
larch()->paths('app', 'Modules');Larch skips folders named vendor, node_modules, tests and Tests wherever they appear.
To skip other folders, replace that list:
larch()->exclude('vendor', 'node_modules', 'tests', 'Tests', 'Legacy');