Search by

noldors / deptrac-config

noldors

Opt-in native Deptrac presets for explicit PHP architecture boundaries.

Package info

github.com/noldor/deptrac-config

pkg:composer/noldors/deptrac-config

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-11-07 17:22 UTC

This package is auto-updated.

Last update: 2026-11-07 17:32:08 UTC


README

Two opt-in native Deptrac presets for explicitly selected PHP application roles. No application or existing PHPStan rule is migrated by installing it.

Packagist · Source · Releases · Issues

Requires PHP 8.2+ and Deptrac 4.7.x from the 4.7.2 baseline. The committed development lock pins the actual checked toolchain. Package development currently requires PHP 8.5 because its PHPUnit and formatter dependencies do; only Linux/PHP 8.5 was exercised in the pilot.

Installation and connection

Install the tagged package from Packagist as a development dependency:

composer require --dev noldors/deptrac-config:^0.1

The library requires Deptrac directly; it is not supplied through downstream require-dev.

Copy the appropriate transport entry and facade entry into the consuming project's root. Adapt every role selector and input path to that project's approved architecture. The examples are templates for that root, not runnable configurations for this package directory.

Run the selected policies independently:

vendor/bin/deptrac analyse --config-file=deptrac.usecase-transport.yaml
vendor/bin/deptrac analyse --config-file=deptrac.di-facades.yaml

A project adopting both policies must require both statuses in its local and CI checks. Neither command installs or updates dependencies. Missing setup is a failed/incomplete check.

Preset Required project parameters Prohibition
Use-case transport noldors.architecture.use_cases, noldors.architecture.transport_types Selected use-case classes must not reference selected transport types.
DI facades noldors.architecture.di_classes Selected DI classes must not reference Laravel facade types.

Parameter values are delimited PCRE patterns for the native classNameRegex collector, for example '#^Company\\Application\\UseCases\\#i' in single-quoted YAML. Include the namespace boundary and intentional case policy. Missing parameters fail configuration; a well-formed pattern matching no source classes can produce no violations. Prove the intended source group with a known rejected example during adoption.

Scope and limitations

Each policy is a partial two-layer view, not a complete application architecture. Unrelated uncollected dependencies are intentionally outside its prohibition and are reported as uncovered by native Deptrac. Do not use --fail-on-uncovered with these partial views. Do not import both presets into one entry: their independent prohibitions require either independent runs or a complete project-owned combined matrix.

The presets select class, function and function_call emitters. Do not add the file-level use emitter when preserving these class-local restrictions: it can assign an unrelated import to a selected class sharing the file. Source and forbidden groups must be disjoint. Namespace parameters do not reproduce inherited source-class selection or lifecycle/path exclusions automatically. Native boolean, inheritance and directory collectors can express reviewed project selections; configuration guidance explains the merge and coverage constraints.

The facade preset recognizes the framework namespace plus parsed descendants of Illuminate\Support\Facades\Facade. Composer autoload does not supply missing AST ancestry. Include relevant parent source files when custom facades extend unparsed vendor intermediates. This can change the input scope and cost.

Native Deptrac configuration does not replace method/argument-sensitive validator rules, service-locator behavior, retained-object lifetime analysis or readonly/property checks. Keep existing PHPStan coverage until the individual replacement is demonstrated. See observed pilot results.

Exceptions

Keep exact source-class to target-class skip_violations entries in the consuming project, with human approval, reason, owner and review condition. Such an exception permits the dependency pair, including additional references between those classes. The package ships no baseline or application-specific exception.

Development

Clone the source repository, explicitly install the committed development graph with composer install --no-plugins --no-scripts, then run composer check. It runs formatting verification, PHPStan and the native CLI integration tests; the checks never perform installation.

Development fixtures are created under temporary directories and removed after each test. The two distributed policy files contain no custom parser, collector, command, plugin or framework bootstrap. The Composer distribution includes the native policies and documentation; tests, caches and installed dependencies stay outside it.