mamuz / php-dependency-analysis
Static code analysis to find violations in a dependency graph
Installs: 107 865
Dependents: 68
Suggesters: 0
Security: 0
Stars: 564
Watchers: 29
Forks: 45
Open Issues: 15
Type:project
Requires
- php: ^7.3
- ext-json: *
- clue/graph: ~0.8
- doctrine/collections: ~1.0
- graphp/algorithms: ~0.8.1
- graphp/graphviz: ~0.2.0
- nikic/php-parser: ~4.0
- phpdocumentor/reflection-docblock: ~4.0
- psr/log: ~1.0
- symfony/console: ~4.2
- symfony/finder: ~4.2
- symfony/yaml: ~4.2
Requires (Dev)
- ext-simplexml: *
- codeception/codeception: ^2.5
- mockery/mockery: ~1.2
- dev-master
- v2.0.2
- v2.0.1
- v2.0.0
- v1.3.1
- v1.3.0
- v1.2.0
- v1.1.1
- v1.1.0
- v1.0.0
- v0.6.1
- v0.6.0
- v0.5.3
- v0.5.2
- v0.5.1
- v0.5.0
- v0.4.2
- v0.4.1
- v0.4.0
- v0.3.4
- v0.3.3
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.1
- v0.2.0
- v0.1.3
- v0.1.0
- v0.1.0-beta
- v0.0.1
- v0.0.1-beta.3
- v0.0.1-beta.2
- v0.0.1-beta
- dev-dependabot/composer/guzzlehttp/guzzle-6.5.8
- dev-dependabot/composer/guzzlehttp/psr7-1.8.5
- dev-dependabot/composer/codeception/codeception-3.1.3
This package is auto-updated.
Last update: 2024-11-21 22:47:07 UTC
README
PhpDependencyAnalysis is an extendable static code analysis for object-oriented
PHP-Projects to generate dependency graphs
from abstract datatypes (Classes, Interfaces and Traits) based on namespaces
.
Dependencies can be aggregated to build graphs for several levels, like Package-Level or Layer-Level.
Each dependency can be verified to a defined architecture.
Read the Introduction-Chapter for further informations.
Example
See more examples.
Installation
As a Docker Image (recommend way)
docker pull mamuz/phpda
As a Composer Dependency
NOTE: For graph creation GraphViz
is required on your machine, which is
an open source graph visualization software and available for the most platforms.
$ composer require --dev mamuz/php-dependency-analysis
As a Phar
Since version 2.0.0 not supported anymore.
Features
- High customizing level
- Graph creation on customized levels respectively different scopes and layers
- Supports Usage-Graph, Call-Graph and Inheritance-Graph
- Dependencies can be aggregated such as to a package, a module or a layer
- Detecting cycles and violations between layers in a tiered architecture
- Verifiying dependency graph against a user-defined reference architecture
- Collected namespaces of dependencies are modifiable to meet custom use cases
- Printing graphs in several formats (HTML, SVG, DOT, JSON)
- Extandable by adding user-defined plugins for collecting and displaying
- Compatible to PHP7 Features, like
Return Type Declarations
andAnonymous Classes
Usage
Phpda can run out of the box by using a prepared configuration
.
As you can see configuration is defined by a YAML
file.
To provide your own configuration create a yml file, e.g. located in ./phpda.yml
:
mode: 'usage' source: './src' filePattern: '*.php' ignore: 'tests' formatter: 'PhpDA\Writer\Strategy\Svg' target: './phpda.svg' groupLength: 1 visitor: - PhpDA\Parser\Visitor\TagCollector - PhpDA\Parser\Visitor\SuperglobalCollector visitorOptions: PhpDA\Parser\Visitor\Required\DeclaredNamespaceCollector: {minDepth: 2, sliceLength: 2} PhpDA\Parser\Visitor\Required\MetaNamespaceCollector: {minDepth: 2, sliceLength: 2} PhpDA\Parser\Visitor\Required\UsedNamespaceCollector: {minDepth: 2, sliceLength: 2} PhpDA\Parser\Visitor\TagCollector: {minDepth: 2, sliceLength: 2}
Perform an analysis with that configuration:
$ docker run --rm -v $PWD:/app mamuz/phpda
Read the Configuration-Chapter to get knowledge about all available options.
Wiki
Code of Conduct
As contributors and maintainers of this project you have to respect the Code of Coduct
Changelog
See record of changes made to this project here
Contributing
Before opening up a pull-request please read the Contributing-Guideline
Alternatives
Check the resources in Satic Analysis Section at Awesome PHP