PHP code example of paglliac / dependency-analysis
1. Go to this page and download the library: Download paglliac/dependency-analysis library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
return [
/**
* REQUIRED
* Dependencies Graph
*
* Description of valid dependencies in project
*
* This config means
*
* Package (every class in namespace) \Domain can use only classes from namespace \Domain or vendor dependencies
* Package \Application can use only classes from namespaces \Domain, \Application or vendor dependencies
* Package \Infrastructure can use only classes from namespaces \Domain, \Application, \Infrastructure or vendor dependencies
*/
'dependencies' => [
'\Domain' => null,
'\Application' => ['\Domain'],
'\Infrastructure' => ['\Domain', '\Application']
],
/**
* REQUIRED
* Source path where dependencies will be analyzed
*/
'path' => __DIR__,
/**
* OPTIONAL
*
* Make available to use vendor dependencies in whole project
*
* true - all project classes can use vendor dependencies
* false - all project can not use vendor dependencies
*/
'skip_vendor_dir' => true,
/**
* OPTIONAL
* Flag that define how to do when some files placed in namespaces not presented in Dependencies Graph
*
* true - mark class as having incorrect dependencies
* false - skip this file
*
* For example, in directory we have namespace \SomeNamespace with class \SomeNamespace\SomeClass
* if flag is true, it will be marked as incorrect file, if flag is true, this file wil be marked as correct
*/
'fail_on_non_presented_namespace' => false,
/**
* OPTIONAL
* Flag for php parser, correct values:
*
* PhpParser\ParserFactory::PREFER_PHP7 - 1 (default)
* PhpParser\ParserFactory::PREFER_PHP5 - 2
* PhpParser\ParserFactory::ONLY_PHP7 - 3
* PhpParser\ParserFactory::ONLY_PHP5 - 4
*/
'php_version' => PhpParser\ParserFactory::PREFER_PHP7,
/**
* OPTIONAL
*
* List of allowed files extensions, all files with other extensions will be skipped from analysis
*
* Default - ['php']
*/
'allowed_extensions' => ['php']
];
/vendor/bin/php-da -c config.php [files filter]
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.