Download the PHP package koriit/phpdeps without Composer
On this page you can find all versions of the php package koriit/phpdeps. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download koriit/phpdeps
More information about koriit/phpdeps
Files in koriit/phpdeps
Package phpdeps
Short Description Library for finding circular dependencies between modules
License MIT
Homepage https://github.com/Koriit/PHPDeps
Informations about the package phpdeps
= PHPDeps :toc:
image:https://travis-ci.org/Koriit/PHPDeps.svg?branch=master[Build Status, link="https://travis-ci.org/Koriit/PHPDeps"]
image:https://coveralls.io/repos/github/Koriit/PHPDeps/badge.svg?branch=master[Coverage Status, link="https://coveralls.io/github/Koriit/PHPDeps?branch=master"] image:https://scrutinizer-ci.com/g/Koriit/PHPDeps/badges/quality-score.png?b=master[Scrutinizer Code Quality, link="https://scrutinizer-ci.com/g/Koriit/PHPDeps/?branch=master"] image:https://styleci.io/repos/105358876/shield?branch=master[StyleCI, link="https://styleci.io/repos/105358876"] image:https://insight.sensiolabs.com/projects/d0be02a7-7d54-4d44-9b45-cda5abdf44fe/mini.png[SensioLabsInsight, link="https://insight.sensiolabs.com/projects/d0be02a7-7d54-4d44-9b45-cda5abdf44fe"]
image:https://poser.pugx.org/koriit/phpdeps/v/stable[Latest Stable Version, link="https://packagist.org/packages/koriit/phpdeps"] image:https://poser.pugx.org/koriit/phpdeps/license[License, link="https://packagist.org/packages/koriit/phpdeps"]
== 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
PHPDeps is available via composer:
[source,shell]
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?
This is a general programming problem. If this subject is new to you, or you just need a refresher here are some quick references:
. http://lattix.com/blog/2017/07/26/why-cyclic-dependencies-are-bad[Why Cyclic Dependencies are Bad] . http://lorifpeterson.com/?p=24[What is circular dependency and why is it bad?] . https://en.wikipedia.org/wiki/Circular_dependency[Circular dependency] . https://en.wikipedia.org/wiki/Acyclic_dependencies_principle[Acyclic dependencies principle] . http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod[The Principles of OOD] (The Acyclic Dependencies Principle part; in the end, most of the writers refer to this piece of literature)
== Approach
[NOTE,caption=TL;DR]
If you are using https://www.php-fig.org/psr/psr-4[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:
[source,php]
<PHPDeps xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/koriit/phpdeps/phpdeps.xsd">
<Modules> <!--1-->
<Module>
<Name>PHPDepsApplication</Name> <!--2-->
<Namespace>Koriit\PHPDeps\PHPDepsApplication</Namespace> <!--3-->
<Path>./src/PHPDeps/PHPDepsApplication.php</Path> <!--4-->
</Module>
</Modules>
<Detectors> <!--5-->
<ModuleDetector>
<Namespace>Koriit\PHPDeps</Namespace> <!--6-->
<Path>./src/PHPDeps</Path> <!--7-->
</ModuleDetector>
</Detectors>
<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:
[source,shell]
----
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
[options="header",cols="^,30%,60%"]
|===================================================================================================================
| Code | Name | Description
| 0 | 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
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
* *