PHPackages                             xandrw/architecture-enforcer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. xandrw/architecture-enforcer

ActiveLibrary[CLI &amp; Console](/categories/cli)

xandrw/architecture-enforcer
============================

Console command that checks your project's structure against an architecture config

v1.5.7(1y ago)127MITPHPPHP &gt;= 8.1

Since Apr 5Pushed 1y ago2 watchersCompare

[ Source](https://github.com/xandrw/architecture-enforcer)[ Packagist](https://packagist.org/packages/xandrw/architecture-enforcer)[ RSS](/packages/xandrw-architecture-enforcer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

PHP Architecture Enforcer
=========================

[](#php-architecture-enforcer)

A command-line tool that recursively scans a given app source directory, analyzes the `.php` files for `namespace` and `use` statements, and checks them against a defined `architecture` config. If a file uses a `dependency` that is outside the allowed `scope` for its `layer`, the command will display all errors along with their file names and offending line numbers.

---

### Installation

[](#installation)

Install the tool as a development dependency using Composer:

```
composer require --dev xandrw/architecture-enforcer
```

Or you can install it globally

```
composer global require xandrw/architecture-enforcer
```

---

### Configuration

[](#configuration)

The configuration file defines your application's layers and their allowed dependencies.

#### Example: Clean Architecture

[](#example-clean-architecture)

```
// project-root/config/architecture.php
