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
StructArmed 0.8.0 introduces a new rule: Psr4DirectoryExistsRule.
This rule detects PSR-4 directory registrations in composer.json that do not exist on disk.
Given this composer.json configuration:
{
"autoload": {
"psr-4": {
"view\\": "directory/not/exists"
}
}
}
When using the PSR-4 preset, StructArmed will report the violation:
StructArmed 0.8.0 — Architecture Enforcement
=================================================
Found 1 violation(s):
─────────────────────────────────────────────────
✗ [psr4.source_paths.must_exist_on_disk]
PSR-4 source path(s) [directory/not/exists] declared in composer.json do not exist on disk
→ /Users/samsonasik/www/yourapp/composer.json:1
Layer: Source
─────────────────────────────────────────────────
1 violation(s) found • 0.34s
composer.json by @samsonasik in https://github.com/boundwize/structarmed/pull/100if block in ChainLayerResolver by @samsonasik in https://github.com/boundwize/structarmed/pull/98Full Changelog: https://github.com/boundwize/structarmed/compare/0.7.12...0.8.0
                          ![PHPStan
StructArmed 0.7.0 adds a new PSR-15 preset for projects that use HTTP middleware and request handlers.
This release helps keep PSR-15 naming and interface contracts consistent across your codebase, especially in Mezzio and other PSR-15 based applications.
use Boundwize\StructArmed\Architecture;
use Boundwize\StructArmed\Preset\Preset;
return Architecture::define()
->withPreset(Preset::PSR15(
sourcePaths: ['src/'],
));
                                              ![PHPStan]
  ![PHPStan]
Until now, layers were resolved purely by path. In 0.5.0, you can define layers through namespace regex patterns using the new layerPattern() method. This is the natural choice for codebases where the architecture lives in the namespace tree rather than the directory structure.
return Architecture::define()
->layerPattern('API', '/^App\\\\API\\\\.*$/')
->layerPattern('HTTP', '/^App\\\\HTTP\\\\.*$/')
->layerPattern('Database', '/^App\\\\Database\\\\.*$/');
An optional third argument acts as an exclude filter — classes whose FQN matches it are skipped even when the primary pattern matches:
->layerPattern('HTTP', '/^App\\\\HTTP\\\\.*$/', '/^App\\\\HTTP\\\\URI$/')
->layerPattern('URI', '/^App\\\\HTTP\\\\URI$/')
Once layers are defined (via layer() or layerPattern()), declare the full allowed-dependency map in one place with ruleset(). Any dependency that resolves to a layer not listed is a violation:
->ruleset([
'API' => ['HTTP'], // API may only depend on HTTP
'HTTP' => ['Database'], // HTTP may only depend on Database
'Database' => [], // Database must not depend on any layer
])
Layers absent from the map are not checked. Same-layer dependencies and dependencies on external (non-registered) classes are always allowed.
When a specific class-to-class dependency is a known exception, suppress it without disabling the whole layer rule:
->skipClassViolation('App\\HTTP\\ResponseTrait', [
'App\\Pager\\PagerInterface',
])
->skipClassViolation('App\\Log\\ChromeLoggerHandler', 'App\\HTTP\\ResponseInterface')
Test files routinely cross layer boundaries by design. skipPathsForRuleset() excludes paths from ruleset evaluation while still scanning them for all other rules (e.g. PSR-4 namespace checks):
->skipPathsForRuleset(['*tests*', '*fixtures*'])
This is distinct from skipPaths() / skipPath(), which exclude files from all analysis.
The class collector now correctly detects and handles traits, so trait-defined dependencies are included in layer resolution and ruleset evaluation.
layerPattern() and ruleset() are additive — existing configs using layer() and individual rule() calls continue to work unchanged. Mix both styles freely within the same Architecture::define() chain.
Full Changelog: https://github.com/boundwize/structarmed/compare/0.4.5...0.5.0
  ![PHPStan]
  ![PHPStan]
  ![PHPStan]
  ![PHPStan]
  ![PHPStan]
  ![PHPStan]
  ![PHPStan]
  ![PHPStan]
  ![PHPStan]
  ![PHPStan]
  ![PHPStan]
  ![PHPStan]
  ![PHPStan]
  ![PHPStan]
  ![PHPStan]
  ![PHPStan]
  ![PHPStan]
  ![PHPStan]