PHPackages                             preee/php-dependency-analysis - 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. preee/php-dependency-analysis

ActiveProject[Testing &amp; Quality](/categories/testing)

preee/php-dependency-analysis
=============================

Static code analysis to find violations in a dependency graph

v1.4.1(7y ago)03922MITPHPPHP ^5.6 || ^7.0

Since Oct 7Pushed 7y ago1 watchersCompare

[ Source](https://github.com/preee/PhpDependencyAnalysis)[ Packagist](https://packagist.org/packages/preee/php-dependency-analysis)[ Docs](https://github.com/mamuz/PhpDependencyAnalysis)[ RSS](/packages/preee-php-dependency-analysis/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (13)Versions (31)Used By (0)

PhpDependencyAnalysis
=====================

[](#phpdependencyanalysis)

[![Author](https://camo.githubusercontent.com/e49859db77ebe675300539af2d01c10b7568b92df2dbbd190335170cd198e5fa/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d406d616d757a5f64652d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/mamuz_de)[![Build Status](https://camo.githubusercontent.com/c975b59e7604a442b18a090638c04f8f368f702efe26264275332699b9e4acb8/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d616d757a2f506870446570656e64656e6379416e616c797369732e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/mamuz/PhpDependencyAnalysis)[![Latest Stable Version](https://camo.githubusercontent.com/73572d886c9819e3e4ea9d6713306dbe6e70430cca1a2cda8ca8118ab1cfc057/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d616d757a2f7068702d646570656e64656e63792d616e616c797369732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mamuz/php-dependency-analysis)[![Total Downloads](https://camo.githubusercontent.com/023898e974937e2efaf02785be88a9a65e801656cb6105978cea48a8220c765e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d616d757a2f7068702d646570656e64656e63792d616e616c797369732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mamuz/php-dependency-analysis)[![License](https://camo.githubusercontent.com/3b342fa879461d206d96a98c79ff4ea24347155056528ac73b17556d5a2de961/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d616d757a2f7068702d646570656e64656e63792d616e616c797369732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mamuz/php-dependency-analysis)

PhpDependencyAnalysis is an extendable static code analysis for object-oriented PHP-Projects to generate [`dependency graphs`](http://en.wikipedia.org/wiki/Dependency_graph)from abstract datatypes (Classes, Interfaces and Traits) based on [`namespaces`](http://php.net/manual/en/language.namespaces.php). 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](https://github.com/mamuz/PhpDependencyAnalysis/wiki/1.-Introduction) for further informations.

### Example

[](#example)

[![](https://camo.githubusercontent.com/0bff2e1b849b3395f53ad499a2496764f48886e0674aa39b06f6dca7e0b363b1/68747470733a2f2f63646e2e7261776769742e636f6d2f6d616d757a2f506870446570656e64656e6379416e616c797369732f6d61737465722f74657374732f5f646174612f7376672f6578706563746174696f6e2f7061636b616765732e737667)](https://camo.githubusercontent.com/0bff2e1b849b3395f53ad499a2496764f48886e0674aa39b06f6dca7e0b363b1/68747470733a2f2f63646e2e7261776769742e636f6d2f6d616d757a2f506870446570656e64656e6379416e616c797369732f6d61737465722f74657374732f5f646174612f7376672f6578706563746174696f6e2f7061636b616765732e737667)

See more [examples](https://github.com/mamuz/PhpDependencyAnalysis/wiki/4.-Examples).

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

[](#installation)

For graph creation [`GraphViz`](http://www.graphviz.org/) is required on your machine, which is an open source graph visualization software and available for the most platforms.

After installing [`GraphViz`](http://www.graphviz.org/) the recommended way to install [`mamuz/php-dependency-analysis`](https://packagist.org/packages/mamuz/php-dependency-analysis) is..

### As a Phar

[](#as-a-phar)

```
$ curl -OsSL https://raw.github.com/mamuz/PhpDependencyAnalysis/master/download/phpda.pubkey
$ curl -OsSL https://raw.github.com/mamuz/PhpDependencyAnalysis/master/download/phpda
$ chmod +x phpda
```

The three lines above will, in order:

- Download the public key to the current directory
- Download the phar file to the current directory
- Make the phar file executable

The phar file is securely signed with OpenSSL. To be able to execute the phar file, the public key must be named as the phar file, with `.pubkey` added, and must be placed in the same directory. That means don't change the name and location of the public key.

#### Update

[](#update)

Use the provided update command to get the latest version.

```
$ phpda update
```

### As a Composer Dependency

[](#as-a-composer-dependency)

```
$ composer require --dev mamuz/php-dependency-analysis
```

Features
--------

[](#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`](https://wiki.php.net/rfc/return_types) and [`Anonymous Classes`](https://wiki.php.net/rfc/anonymous_classes)

Usage
-----

[](#usage)

Phpda can run out of the box by using a prepared [`configuration`](https://github.com/mamuz/PhpDependencyAnalysis/blob/master/phpda.yml.dist). As you can see configuration is defined by a [`YAML`](http://en.wikipedia.org/wiki/YAML) file.

To provide your own configuration create a yml file, e.g. located in `./myconfig.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:

```
$ phpda analyze ./myconfig.yml
```

After that open the graph file `./phpda.svg` with your prefered tool.

Read the [Configuration-Chapter](https://github.com/mamuz/PhpDependencyAnalysis/wiki/3.-Configuration)to get knowledge about all available options.

[Wiki](https://github.com/mamuz/PhpDependencyAnalysis/wiki)
-----------------------------------------------------------

[](#wiki)

1. [Introduction](https://github.com/mamuz/PhpDependencyAnalysis/wiki/1.-Introduction)
2. [Requirements](https://github.com/mamuz/PhpDependencyAnalysis/wiki/2.-Requirements)
3. [Configuration](https://github.com/mamuz/PhpDependencyAnalysis/wiki/3.-Configuration)
4. [Examples](https://github.com/mamuz/PhpDependencyAnalysis/wiki/4.-Examples)
5. [Plugins](https://github.com/mamuz/PhpDependencyAnalysis/wiki/5.-Plugins)

[Code of Conduct](https://github.com/mamuz/PhpDependencyAnalysis/blob/master/.github/CODE_OF_CONDUCT.md)
--------------------------------------------------------------------------------------------------------

[](#code-of-conduct)

As contributors and maintainers of this project you have to respect the [Code of Coduct](https://github.com/mamuz/PhpDependencyAnalysis/blob/master/.github/CODE_OF_CONDUCT.md)

[Changelog](https://github.com/mamuz/PhpDependencyAnalysis/blob/master/CHANGELOG.md)
------------------------------------------------------------------------------------

[](#changelog)

See record of changes made to this project [here](https://github.com/mamuz/PhpDependencyAnalysis/blob/master/CHANGELOG.md)

[Contributing](https://github.com/mamuz/PhpDependencyAnalysis/blob/master/.github/CONTRIBUTING.md)
--------------------------------------------------------------------------------------------------

[](#contributing)

Before opening up a pull-request please read the [Contributing-Guideline](https://github.com/mamuz/PhpDependencyAnalysis/blob/master/.github/CONTRIBUTING.md)

Alternatives
------------

[](#alternatives)

Check the resources in [Code Analysis Section at Awesome PHP](https://github.com/ziadoz/awesome-php#code-analysis)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 97.6% 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 ~51 days

Recently: every ~250 days

Total

30

Last Release

2734d ago

Major Versions

v0.6.1 → v1.0.02016-02-07

PHP version history (4 changes)v0.0.1-betaPHP &gt;=5.4

v0.1.0-betaPHP &gt;=5.3.3

v1.0.0PHP &gt;=5.5

v1.3.0PHP ^5.6 || ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ed86b6dea42bb7b8f3db93c859a083243bc81ac6199a6357ea5eb137b2bcde1e?d=identicon)[preee](/maintainers/preee)

---

Top Contributors

[![mamuz](https://avatars.githubusercontent.com/u/4173317?v=4)](https://github.com/mamuz "mamuz (570 commits)")[![preee](https://avatars.githubusercontent.com/u/2489682?v=4)](https://github.com/preee "preee (5 commits)")[![cawolf](https://avatars.githubusercontent.com/u/1932623?v=4)](https://github.com/cawolf "cawolf (3 commits)")[![otruffer](https://avatars.githubusercontent.com/u/410402?v=4)](https://github.com/otruffer "otruffer (3 commits)")[![garex](https://avatars.githubusercontent.com/u/77981?v=4)](https://github.com/garex "garex (1 commits)")[![jakzal](https://avatars.githubusercontent.com/u/190447?v=4)](https://github.com/jakzal "jakzal (1 commits)")[![mikaelmattsson](https://avatars.githubusercontent.com/u/2428696?v=4)](https://github.com/mikaelmattsson "mikaelmattsson (1 commits)")

---

Tags

dependencyanalysisarchitecturegraphphpda

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/preee-php-dependency-analysis/health.svg)

```
[![Health](https://phpackages.com/badges/preee-php-dependency-analysis/health.svg)](https://phpackages.com/packages/preee-php-dependency-analysis)
```

###  Alternatives

[mamuz/php-dependency-analysis

Static code analysis to find violations in a dependency graph

573108.5k65](/packages/mamuz-php-dependency-analysis)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k26.2M1.8k](/packages/infection-infection)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[phpbench/phpbench

PHP Benchmarking Framework

2.0k13.0M627](/packages/phpbench-phpbench)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)

PHPackages © 2026

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