PHPackages                             cooldevguys/phpstan-dhexpendency-rules - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. cooldevguys/phpstan-dhexpendency-rules

ActivePhpstan-extension[Testing &amp; Quality](/categories/testing)

cooldevguys/phpstan-dhexpendency-rules
======================================

A set of rules for PHPStan based on the Hexagonal architecture layers dependency

1.0.3(2y ago)0189MITPHPPHP &gt;=7.4.0

Since Jul 31Pushed 2y agoCompare

[ Source](https://github.com/CoolDevGuys/phpstan-dhexpendency-rules)[ Packagist](https://packagist.org/packages/cooldevguys/phpstan-dhexpendency-rules)[ RSS](/packages/cooldevguys-phpstan-dhexpendency-rules/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependencies (3)Versions (5)Used By (0)

phpstan-dhexpendency-rules
==========================

[](#phpstan-dhexpendency-rules)

A set of additional rules for [phpstan](https://github.com/phpstan/phpstan). The intention of this rules is to foment to respect the dependency flow in a hexagonal architecture.

These rules assume that in the typical hexagonal architecture there are 3 layers: **Infrastructure**, **Application** and **Domain**.

There is a flow within these layers, this defines how the dependencies should interact to each other according the layer they are located in, and the flow is: **Infrastructure** ➡️ **Application** ➡️ **Domain**.

The interpretation of this flow is:

- The **Infrastructure** layer can "know" or communicate with the **Application** and **Domain** layers
- The **Application** layer can "known" or communicate ONLY with the **Domain** layer
- The **Domain** layer can ONLY communicate with itself

This ruleset attempts to help verifying the dependency flow is being applied properly in your project.

Installation
------------

[](#installation)

Run

```
composer require --dev cooldevguys/phpstan-dhexpendency-rules
```

If you use PHPStan extension installer, you're all set. If not, you need to manually register all the rules in your `phpstan.neon` file:

```
includes:
  - vendor/cooldevguys/phpstan-dhexpendency-rules/rules.neon
```

Configuration
-------------

[](#configuration)

You need to add your own values as parameters to your phpstan.neon:

```
parameters:
  myVendorName: CoolDevGuys
  vendorStrictMode: true
  ignoredExternalVendors: ['IgnoredVendor']
  infrastructureLayerName: Infra
  applicationLayerName: App
  domainLayerName: Dom
```

- `myVendorName` (string): Your project vendor
- `vendorStrictMode` (bool): Indicates if you want to validate that no external vendors are imported from **Application** or **Domain** layers
- `ignoredExternalVendors` (string\[\]): A list of external vendors that you want to exclude from the check
- `infrastructureLayerName`(string): The name you define in your project for the **Infrastructure** layer
- `applicationLayerName`(string): The name you define in your project for the **Application** layer
- `domainLayerName`(string): The name you define in your project for the **Domain** layer

Rules
-----

[](#rules)

Currently there are two rules:

- `LayersDependencyFlowRule`
- `NoExternalVendorsAllowedFromDomainRule`

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~7 days

Total

4

Last Release

1046d ago

PHP version history (2 changes)1.0.0PHP ^7.4|^8.2

1.0.1PHP &gt;=7.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/0c27af6d26b116da71d95defbd6898f833355c12e8c4560dbb32a3050be0546f?d=identicon)[ealejandrorg@gmail.com](/maintainers/ealejandrorg@gmail.com)

---

Top Contributors

[![alexromer0](https://avatars.githubusercontent.com/u/22891621?v=4)](https://github.com/alexromer0 "alexromer0 (8 commits)")

---

Tags

PHPStanhexagonal-architecturephpstan-rules

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cooldevguys-phpstan-dhexpendency-rules/health.svg)

```
[![Health](https://phpackages.com/badges/cooldevguys-phpstan-dhexpendency-rules/health.svg)](https://phpackages.com/packages/cooldevguys-phpstan-dhexpendency-rules)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.5k55.4M8.4k](/packages/larastan-larastan)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

79475.7M2.2k](/packages/phpstan-phpstan-symfony)[shipmonk/dead-code-detector

Dead code detector to find unused PHP code via PHPStan extension. Can automatically remove dead PHP code. Supports libraries like Symfony, Doctrine, PHPUnit etc. Detects dead cycles. Can detect dead code that is tested.

4853.5M91](/packages/shipmonk-dead-code-detector)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67272.8M1.4k](/packages/phpstan-phpstan-doctrine)[orrison/meliorstan

Provides PHPStan rules for improved code quality by detecting code smells and possible issues. In addition to enforcing particular naming and code style conventions to reduce bike-shedding.

1915.9k5](/packages/orrison-meliorstan)[wp-cli/wp-cli-tests

WP-CLI testing framework

423.1M142](/packages/wp-cli-wp-cli-tests)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
