php dependency analysis
1.0.0
PHP DA는 프로젝트 내에서 확인 및 지원 종속성을위한 도구입니다.
예를 들어:
[
' dependencies ' => [
' Domain ' => null ,
' Application ' => [ ' Domain ' ],
' Infrastructure ' => [ ' Domain ' , ' Application ' ]
]
];즉, 도메인 네임 스페이스의 모든 클래스는이 네임 스페이스의 클래스 만 사용하고 공급 업체 (구성)를 사용해야합니다.
응용 프로그램 의 모든 클래스는 도메인 및 응용 프로그램 네임 스페이스에서 클래스를 사용할 수 있지만 인프라 등은 없습니다.
정의 된 종속성 그래프를 만족시키지 못하는 종속성을 사용하는 일부 클래스는 보고서에 오류를 제공합니다.
Have been analyzed 4 files
You have dependency problems in 2 files in your project:
Class ApplicationTrackingService have errors:
- Class ApplicationTrackingService using class InfrastructureShipImplementation which not satisfy dependency graph
Class DomainCargo have errors:
- Class DomainCargo using class ApplicationTrackingService which not satisfy dependency graph
- Class DomainCargo using class InfrastructureShipImplementation which not satisfy dependency graph
예를 들어 어떤 경우에는 유용 할 수 있습니다.
작곡가를 사용하여 라이브러리를 설치하십시오
composer require paglliac/dependency-analysis
프로젝트의 루트에 configuration 파일 config.php 추가 :
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 SomeNamespaceSomeClass
* 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:
*
* PhpParserParserFactory::PREFER_PHP7 - 1 (default)
* PhpParserParserFactory::PREFER_PHP5 - 2
* PhpParserParserFactory::ONLY_PHP7 - 3
* PhpParserParserFactory::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]
옵션 :
-c 또는 --config config 구성 파일에 대한 상대 경로와 함께 옵션이 필요합니다.논쟁 :
[files filter] 분석용 파일 목록, ci에서 사용하는 것이 유용합니다 -diff Have been analyzed 4 files
You have dependency problems in 2 files in your project:
Class ApplicationTrackingService have errors:
- Class ApplicationTrackingService using class InfrastructureShipImplementation which not satisfy dependency graph
Class DomainCargo have errors:
- Class DomainCargo using class ApplicationTrackingService which not satisfy dependency graph
- Class DomainCargo using class InfrastructureShipImplementation which not satisfy dependency graph