Description
PhpDependencyAnalysis is an extendable static code analysis for object-oriented
PHP-Projects to provide dependency graphs
for 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 your defined architecture.
Read the Introduction-Chapter for further informations.
PhpDependencyAnalysis alternatives and similar libraries
Based on the "Code Analysis" category.
Alternatively, view PhpDependencyAnalysis alternatives based on common mentions on social networks and blogs.
-
phan
Phan is a static analyzer for PHP. Phan prefers to avoid false-positives and attempts to prove incorrectness rather than correctness. -
PHP Mess Detector
PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD. PHPMD can be seen as an user friendly frontend application for the raw metrics stream measured by PHP Depend. -
Better Reflection
:crystal_ball: Better Reflection is a reflection API that aims to improve and provide more features than PHP's built-in reflection API. -
PHP Code Sniffer
PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards. -
PHP Semantic Versioning Checker
Compares two source sets and determines the appropriate semantic versioning to apply. -
PHPCheckstyle
PHPCheckstyle is an open-source tool that helps PHP programmers adhere to certain coding conventions.
InfluxDB - Purpose built for real-time analytics at any scale.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of PhpDependencyAnalysis or a related project?
README
PhpDependencyAnalysis
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
*Note that all licence references and agreements mentioned in the PhpDependencyAnalysis README section above
are relevant to that project's source code only.