Repository navigation
Released: StructArmed 0.19.0
StructArmed 0.19.0 introduces configurable project base paths and a new architecture rule for restricting constant usage.
This release introduces:
--basepathand its-dalias for analysing projects from a separate working directory;- the new
MayNotUseConstantRulefor restricting constant usage within architecture layers; - additional DDD preset restrictions for
STDIN,STDOUT, andSTDERR; - dependency update and internal cleanup.
Configurable Project Base Path
StructArmed now supports specifying the project root through --basepath or its short alias -d.
This is useful when StructArmed is installed in a separate tools directory instead of the project's root directory.
For example:
composer.json
src/
tests/
tools/
└── structarmed/
├── composer.json
├── structarmed.php
└── vendor/
From tools/structarmed, run:
vendor/bin/structarmed analyse --basepath=../../Or use the shorter form:
vendor/bin/structarmed analyse -d ../../The specified base path is used for resolving:
- architecture layer paths;
- scan paths;
- the project's
composer.jsonand PSR-4 mappings; - cache directories;
- baseline paths.
Configuration discovery checks the current working directory first, followed by the specified base path. An explicit --config remains relative to the current working directory.
The option also works with cache clearing:
vendor/bin/structarmed --basepath=../../ --clear-cacheCLI options may be specified before or after the command.
This makes StructArmed easier to integrate into projects that keep development tools and their dependencies separate from the application.
New MayNotUseConstantRule
StructArmed introduces:
MayNotUseConstantRuleThis rule prevents classes, traits, and enums in a specified architecture layer from using a forbidden constant.
For example:
use Boundwize\StructArmed\Rule\Rules\Usage\MayNotUseConstantRule;
->rule(
'domain_no_php_eol',
new MayNotUseConstantRule(
layer: 'Domain',
constant: 'PHP_EOL',
),
)The rule supports global and namespaced constants:
new MayNotUseConstantRule(
layer: 'Domain',
constant: 'Vendor\\Config\\DEBUG',
)Constant names are matched case-sensitively, while namespace names are matched case-insensitively.
The rule also handles PHP's runtime fallback behavior for unqualified constants inside namespaces.
DDD Preset Improvements
The DDD preset now prevents the Domain layer from directly using these constants:
STDINSTDOUTSTDERR
These restrictions are enabled automatically through:
Preset::DDD()This helps keep domain logic independent of direct console input and output.
Internal Improvements
- Remove unused
RuleViolationCollection::forLayer()andtoJson()methods. - Update
fidry/cpu-core-counterdependency to^1.4. - Update the analysis cache format to accommodate constant usage information.
- Temporarily exclude PHP 8.5 on macOS from CI due to runner setup issues.
What's Changed
- Add
MayNotUseConstantRuleand DDD preset restrictions in #495. - Add configurable project base paths using
--basepathand-din #496. - Improve configuration discovery across working and project directories in #496.
- Remove unused
RuleViolationCollection::forLayer()andtoJson()methods in #476. - Update
fidry/cpu-core-counterto^1.4in #490.
Full Changelog: 0.18.11...0.19.0