Giter Site home page Giter Site logo

brightbyte / phpdependencyanalysis Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mamuz/phpdependencyanalysis

0.0 1.0 0.0 6.83 MB

Static code analysis to find violations in a dependency graph

Home Page: http://mamuz.github.io/PhpDependencyAnalysis/

License: MIT License

Makefile 0.23% PHP 99.56% Batchfile 0.05% Shell 0.16%

phpdependencyanalysis's Introduction

PhpDependencyAnalysis

Author Build Status Latest Stable Version Total Downloads License

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

For graph creation GraphViz is required on your machine, which is an open source graph visualization software and available for the most platforms.

After installing GraphViz the recommended way to install mamuz/php-dependency-analysis is..

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

Use the provided update command to get the latest version.

$ phpda update

As a Composer Dependency

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

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 and Anonymous 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 ./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 to get knowledge about all available options.

  1. Introduction
  2. Requirements
  3. Configuration
  4. Examples
  5. Plugins

As contributors and maintainers of this project you have to respect the Code of Coduct

See record of changes made to this project here

Before opening up a pull-request please read the Contributing-Guideline

Alternatives

Check the resources in Code Analysis Section at Awesome PHP

phpdependencyanalysis's People

Contributors

cawolf avatar garex avatar jakzal avatar mamuz avatar mikaelmattsson avatar otruffer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.