Download the PHP package cooldevguys/phpstan-dhexpendency-rules without Composer
On this page you can find all versions of the php package cooldevguys/phpstan-dhexpendency-rules. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cooldevguys/phpstan-dhexpendency-rules
More information about cooldevguys/phpstan-dhexpendency-rules
Files in cooldevguys/phpstan-dhexpendency-rules
Package phpstan-dhexpendency-rules
Short Description A set of rules for PHPStan based on the Hexagonal architecture layers dependency
License MIT
Informations about the package phpstan-dhexpendency-rules
phpstan-dhexpendency-rules
A set of additional rules for 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
Run
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:
Configuration
You need to add your own values as parameters to your phpstan.neon:
myVendorName
(string): Your project vendorvendorStrictMode
(bool): Indicates if you want to validate that no external vendors are imported from Application or Domain layersignoredExternalVendors
(string[]): A list of external vendors that you want to exclude from the checkinfrastructureLayerName
(string): The name you define in your project for the Infrastructure layerapplicationLayerName
(string): The name you define in your project for the Application layerdomainLayerName
(string): The name you define in your project for the Domain layer
Rules
Currently there are two rules:
LayersDependencyFlowRule
NoExternalVendorsAllowedFromDomainRule