NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist, #2099 most downloaded on Packagist
Configurable PHP architecture guards — define your layers and rules, then keep them enforced
Latest stable
0.21.8
Last release 13 days ago
08 Nov 2026
Ships on a steady schedule
a new release about every 8 days
Nearly every release is documented
notes for 60 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
6 months old
251 releases · first in 2026
Drag across the ruler to compare, or tap a release to open it.
  ![PHPStan]
  ![PHPStan]
Your coding agent can read these notes before it upgrades. Set up the MCP server →
One column per month.
  ![PHPStan]
  ![PHPStan]
Released: structarmed 0.1.2
Full Changelog: https://github.com/boundwize/structarmed/compare/0.1.1...0.1.2
  ![PHPStan]
  ![PHPStan]
  ![PHPStan]
Fix deprecated PHPParser UseUse Stmt by @samsonasik in https://github.com/boundwize/structarmed/pull/4
Released: structarmed 0.0.4
Full Changelog: https://github.com/boundwize/structarmed/compare/0.0.3...0.0.4
  ![PHPStan]
  ![PHPStan]
Released: structarmed 0.0.2
Full Changelog: https://github.com/boundwize/structarmed/compare/0.0.1...0.0.2
This is an early 0.0.1 release. The API should be considered unstable — breaking changes may occur in minor versions before 1.0.0. Feedback, issues, a…
<img width="1600" height="420" alt="Image" src="https://github.com/user-attachments/assets/62b0baa3-d81a-44ec-bd5a-16bb4c5c97f8" />
<br />
structarmed is configurable PHP architecture guards — define your layers and rules, then keep them enforced.
composer require --dev boundwize/structarmed
vendor/bin/structarmed init
Generates a structarmed.php in your project root. Edit it to match your structure, then run:
vendor/bin/structarmed analyse
If violations are found, the output reports each one:
<img width="498" height="214" alt="Image" src="https://github.com/user-attachments/assets/51368d3d-b5bc-4d09-8cbb-cd0b55fca370" />
If everything passes, you get a clean summary:
<img width="460" height="93" alt="Image" src="https://github.com/user-attachments/assets/aeb81a6a-20eb-40be-b68b-889b0349ac37" />
// structarmed.php
use Boundwize\StructArmed\Architecture;
use Boundwize\StructArmed\Preset\Preset;
return Architecture::define()
->withPreset(Preset::PSR4());
->withPresets(Preset::PSR4(), Preset::DDD(), Preset::MVC())
use Boundwize\StructArmed\Architecture;
use Boundwize\StructArmed\Rule\Rules\Layer\MayNotDependOnRule;
use Boundwize\StructArmed\Rule\Rules\Method\MustHaveReturnTypeRule;
return Architecture::define()
->layer('Domain', 'src/Domain/')
->layer('Application', 'src/Application/')
->layer('Infrastructure', 'src/Infrastructure/')
->skip([
'tests/Fixtures/',
'var/cache/*',
DddPreset::ENTITY_MUST_BE_FINAL => ['src/Legacy/'],
])
->rule(
'domain.must_not_depend_on_infrastructure',
new MayNotDependOnRule(from: 'Domain', to: 'Infrastructure', toPath: 'Infrastructure')
)
->rule(
'domain.public_methods_must_have_return_types',
new MustHaveReturnTypeRule(layer: 'Domain')
);
Use rule key constants — never raw strings:
use Boundwize\StructArmed\Preset\Presets\DddPreset;
return Architecture::define()
->layer('Domain', 'src/Domain/')
->layer('Application', 'src/Application/')
->layer('Infrastructure', 'src/Infrastructure/')
->withPreset(Preset::DDD())
// Remove a rule entirely
->withoutRule(DddPreset::DOMAIN_NO_BASE_EXCEPTION)
// Replace a rule with a different configuration
->replaceRule(
DddPreset::ENTITY_MUST_BE_FINAL,
new MustBeFinalRule(layer: 'Domain', classNamePattern: '/Entity$|Aggregate$/')
)
// Add your own custom rule
->rule(
'our.handlers.must_be_in_application',
new NamingConventionRule(
classNamePattern: '/Handler$/',
mustBeInLayer: 'Application'
)
);
->withPreset(Preset::DDD(
maxComplexity: 3, // default: 5
maxMethodLength: 15, // default: 20
enforceFinalEntities: false, // default: true
))
->withPreset(Preset::MVC(
controllerMaxComplexity: 3, // default: 5
controllerMaxDependencies: 4, // default: 5
viewMaxComplexity: 2, // default: 3
))
->withPreset(Preset::PSR4(
sourcePaths: ['src/', 'tests/'], // default: read composer.json PSR-4 paths
))
| Preset | Rules |
|---|---|
Preset::PSR4() |
Verifies configured source paths exist in composer.json autoload or autoload-dev PSR-4 mappings |
Preset::DDD() |
Layer isolation, entity/VO/repository/event/service conventions |
Preset::MVC() |
Layer isolation, thin controllers, model/view/service rules |
Run architecture checks as part of your test suite:
<!-- phpunit.xml -->
<extensions>
<bootstrap class="Boundwize\StructArmed\PHPUnit\StructArmedExtension"/>
</extensions>
Violations cause the test run to fail before any tests execute.
# Analyse with default config discovery
vendor/bin/structarmed analyse
vendor/bin/structarmed analyze
# Analyse only specific paths
vendor/bin/structarmed analyse src
vendor/bin/structarmed analyze src tests
# Custom config path
vendor/bin/structarmed analyse --config=path/to/structarmed.php
vendor/bin/structarmed analyze --config=path/to/structarmed.php
# JSON output (for CI tools)
vendor/bin/structarmed analyse --report=json
vendor/bin/structarmed analyze --report=json
# Generate initial config
vendor/bin/structarmed init
Layers are resolved by file path — no attributes needed on classes:
src/Domain/ → 'Domain'
src/Application/ → 'Application'
src/Infrastructure/ → 'Infrastructure'
Every preset rule has a public constant. Use constants, never raw strings:
// ✅ correct — caught by IDE and static analysis
DddPreset::ENTITY_MUST_BE_FINAL
// ❌ wrong — typo silently does nothing
'ddd.entity.must_be_fnal'
Notes
This is an early 0.0.1 release. The API should be considered unstable — breaking changes may occur in minor versions before 1.0.0. Feedback, issues, and contributions are very welcome at https://github.com/boundwize/structarmed