PHPackages                             koriit/phpdeps - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. koriit/phpdeps

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

koriit/phpdeps
==============

Library for finding circular dependencies between modules

v0.1.0(8y ago)421MITPHPPHP ^5.6 || ^7.0 &lt;7.3

Since May 4Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Koriit/PHPDeps)[ Packagist](https://packagist.org/packages/koriit/phpdeps)[ Docs](https://github.com/Koriit/PHPDeps)[ RSS](/packages/koriit-phpdeps/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

PHPDeps
=======

[](#phpdeps)

Table of Contents

- [About](#about)
- [Install](#install)
- [Why care?](#why-care)
- [Approach](#approach)
- [Basic usage](#basic-usage)
- [Example](#example)
- [Exit codes](#exit-codes)
- [Config](#config)
- [Config example](#config-example)
- [Commands and options](#commands-and-options)

[![Build Status](https://camo.githubusercontent.com/b57f42e258f97dfd76556736c54c5c32645cdefce7d2294f78ef7902e2c893b3/68747470733a2f2f7472617669732d63692e6f72672f4b6f726969742f504850446570732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Koriit/PHPDeps)

[![Coverage Status](https://camo.githubusercontent.com/be5cb9aa3efb5c5309da09f64f29df2a262234cb2a9edcf2f278b0abc5681040/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4b6f726969742f504850446570732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/Koriit/PHPDeps?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/be0dc4eb0c63fb26ad3a6a1fc78bcb811877a48d4efb4388b29d9d9424317702/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4b6f726969742f504850446570732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Koriit/PHPDeps/?branch=master)[![StyleCI](https://camo.githubusercontent.com/ca448df7160c3cf3943daa0a20f8c21289d33b641c850a3917b1212a38fc59f3/68747470733a2f2f7374796c6563692e696f2f7265706f732f3130353335383837362f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/105358876)[![SensioLabsInsight](https://camo.githubusercontent.com/bcc4abcaf01419165259e816b530755c9004ab9c87efd1633743911a53abd807/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f64306265303261372d376435342d346434342d396234352d6364613561626466343466652f6d696e692e706e67)](https://insight.sensiolabs.com/projects/d0be02a7-7d54-4d44-9b45-cda5abdf44fe)

[![Latest Stable Version](https://camo.githubusercontent.com/1b645a645a02428a6b83c9981eaff417551f85bcb20c8f6131494dbf27c8816a/68747470733a2f2f706f7365722e707567782e6f72672f6b6f726969742f706870646570732f762f737461626c65)](https://packagist.org/packages/koriit/phpdeps)[![License](https://camo.githubusercontent.com/a9c91b8a22ac6b2ce629c10be1b0e500cbb787ba701965ac68577188f0a03d90/68747470733a2f2f706f7365722e707567782e6f72672f6b6f726969742f706870646570732f6c6963656e7365)](https://packagist.org/packages/koriit/phpdeps)

About
-----

[](#about)

PHPDeps is a simple tool to detect circular dependencies in your modules, whatever you consider as a module or package.

Module is an organized unit of code, which is supposed to be treated as single entity. By grouping classes and functions into modules we can reason about the design at a higher level of abstraction.

Install
-------

[](#install)

PHPDeps is available via composer:

```
composer require --dev koriit/phpdeps
```

Please, note that PHPDeps is used during the development. It’s not a part of your application, hence `--dev`.

Why care?
---------

[](#why-care)

This is a general programming problem. If this subject is new to you, or you just need a refresher here are some quick references:

1. [Why Cyclic Dependencies are Bad](http://lattix.com/blog/2017/07/26/why-cyclic-dependencies-are-bad)
2. [What is circular dependency and why is it bad?](http://lorifpeterson.com/?p=24)
3. [Circular dependency](https://en.wikipedia.org/wiki/Circular_dependency)
4. [Acyclic dependencies principle](https://en.wikipedia.org/wiki/Acyclic_dependencies_principle)
5. [The Principles of OOD](http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod)(*The Acyclic Dependencies Principle* part; in the end, most of the writers refer to this piece of literature)

Approach
--------

[](#approach)

TL;DR

If you are using [PSR-4](https://www.php-fig.org/psr/psr-4) and importing all classes and function via `use` then you are fine.

PHPDeps detects module usage by reading `use` section of your PHP files. This means that **PHPDeps requires namespaces to be present**.

PHPDeps assumes that all classes and functions belonging to a single module have the same namespace prefix in their fully qualified name.

For example, if we tell PHPDeps that **SomeModule** has namespace of `ACME\Lib\Modules\SomeModule` and PHPDeps analyzes a following file which belongs to **OtherModule**:

```

            PHPDepsApplication
            Koriit\PHPDeps\PHPDepsApplication
            ./src/PHPDeps/PHPDepsApplication.php

            Koriit\PHPDeps
            ./src/PHPDeps

```

1. **First option** is to directly define your modules.
2. Each module needs a name, but currently this is only used for displaying purposes.
3. Each module also needs a namespace prefix, this is used to check whether any other module depends on it. If module is a file then this needs to be fully qualified name of that module.
4. Module path allows PHPDeps to find and analyze your module, this can be either filepath or dirpath.
5. **Second option** is to define a module detector, right now PHPDeps supports detection of only dir based modules.
6. Namespace prefix, directory name of found modules are appended to this to create actual module namespaces.
7. Directory where modules are to be searched for.

Once you have a configuration ready, you can execute:

```
vendor/bin/phpdeps
```

If everything is all right you get nice OK message:

```
[OK] There are no circular dependencies in your modules!
```

If something is amiss, you get:

```
[WARNING] There are circular dependencies in your modules!

In total there are 4 dependency cycles in your modules.

1. Commands -> Modules -> Commands
----------------------------------

2. Commands -> Config -> Modules -> Commands
--------------------------------------------

3. Commands -> Helpers -> Modules -> Commands
---------------------------------------------

4. Commands -> Helpers -> Config -> Modules -> Commands
-------------------------------------------------------
```

Please, note that this example was generated by adding just one dependency to **Commands** module in **Modules** module.

At the moment PHPDeps does not provide any additional help in resolving the circular dependencies problem.

Exit codes
----------

[](#exit-codes)

CodeNameDescription0

OK

Application finished successfully and no issues detected

1

UNEXPECTED\_ERROR

Application was aborted because of an error

**3**

**CIRCULAR\_DEPENDENCIES\_EXIST**

Application finished successfully but dependency cycle has been detected

255

STATUS\_OUT\_OF\_RANGE

Returned status code was out of range

Config
------

[](#config)

Configuration is a simple XML file. Provided XSD allows for code completion and easy validation. Currently, configuration uses simple format consisting of only XML tags and no attributes

- **&lt;PHPDeps&gt;** - Configuration root element.

    - **&lt;Modules&gt;** - Grouping tag for all kinds of module definitions.

        - **&lt;Module&gt;** - Defines and describes a single module.

            - **&lt;Name&gt;** - Module name, used for display purposes.
            - **&lt;Namespace&gt;** - Namespace prefix, to check whether any other module depends on it. If module is a file then this needs to be fully qualified name of that module.
            - **&lt;Path&gt;** - Module path allows PHPDeps to find and analyze your module, this can be either filepath or dirpath.
    - **&lt;Detectors&gt;** - Grouping tag for all kinds of detector definitions.

        - **&lt;ModuleDetector&gt;** - Defines and describes a single basic module detector.

            - **&lt;Namespace&gt;** - Namespace prefix, directory name of found modules are appended to this to create actual module namespaces.
            - **&lt;Path&gt;** - Directory where modules are to be searched for.

Config example
--------------

[](#config-example)

phpdeps.xml

```

            PHPDepsApplication
            Koriit\PHPDeps\PHPDepsApplication
            ./src/PHPDeps/PHPDepsApplication.php

            Koriit\PHPDeps
            ./src/PHPDeps

```

Commands and options
--------------------

[](#commands-and-options)

Please, refer to built-in `help` command.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

Unknown

Total

1

Last Release

2932d ago

### Community

Maintainers

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

---

Top Contributors

[![Koriit](https://avatars.githubusercontent.com/u/8916393?v=4)](https://github.com/Koriit "Koriit (62 commits)")

---

Tags

circular-dependenciesdependenciesphpphpdependenciescircular-dependencies

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/koriit-phpdeps/health.svg)

```
[![Health](https://phpackages.com/badges/koriit-phpdeps/health.svg)](https://phpackages.com/packages/koriit-phpdeps)
```

###  Alternatives

[codewithkyrian/transformers

State-of-the-art Machine Learning for PHP. Run Transformers in PHP

749231.8k5](/packages/codewithkyrian-transformers)[jbzoo/composer-graph

Render composer.json + composer.lock dependencies graph

66741.6k2](/packages/jbzoo-composer-graph)[bacula-web/bacula-web

The open source web based reporting and monitoring tool for Bacula

1537.5k](/packages/bacula-web-bacula-web)

PHPackages © 2026

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