Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php Coupling Detector Laravel Package

akeneo/php-coupling-detector

Detect PHP coupling issues based on configurable rules by analyzing class use statements. Supports forbidden, discouraged, and only rules, with error/warning violations. Includes commands to detect violations and list unused requirements.

View on GitHub
Deep Wiki
Context7

Detect coupling problems

The detect command detects coupling problems for a given file or directory depending on the coupling rules that have been defined:

    php bin/php-coupling-detector detect /path/to/directory
    php bin/php-coupling-detector detect /path/to/file

The exit status of the detect command can be: 0 if no violations have been raised, 10 in case of warnings and 99 in case of errors.

You can save the configuration in a .php_cd file in the root directory of your project. The file must return an instance of Akeneo\CouplingDetector\Configuration\Configuration, which lets you configure the rules and the directories that need to be analyzed. Here is an example below:

   <?php

   $finder = new \Symfony\Component\Finder\Finder();
   $finder
       ->files()
       ->name('*.php')
       ->notPath('foo/bar/');

   $builder = new \Akeneo\CouplingDetector\RuleBuilder();
   
   $rules = [
       $builder->forbids(['bar', 'baz'])->in('foo'),
       $builder->discourages(['too'])->in('zoo'),
       $builder->only(['bla', 'ble', 'blu'])->in('bli'),
   ];

   return new \Akeneo\CouplingDetector\Configuration\Configuration($rules, $finder);
   ?>

You can also use the default finder implementation if you want to analyse all the PHP files of your directory:

   <?php
   
   $builder = new \Akeneo\CouplingDetector\RuleBuilder();
   
   $rules = [
       $builder->forbids(['bar', 'baz'])->in('foo'),
       $builder->discourages(['too'])->in('zoo'),
       $builder->only(['bla', 'ble', 'blu'])->in('bli'),
   ];

   return new \Akeneo\CouplingDetector\Configuration\Configuration(
       $rules,
       new \Akeneo\CouplingDetector\Configuration\DefaultFinder()
   );
   ?>

With the --config-file option you can specify the path to the .php_cd file:

    php bin/php-coupling-detector detect /path/to/dir --config-file=/path/to/my/own_configuration_file.php

With the --format option you can specify the output format:

    php bin/php-coupling-detector /path/to/dir --format=dot
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
andydefer/laravel-notification
adachsoft/cli-process-tester
jhaskell13/laraflow
sebastienheyd/boilerplate-media-manager
ccast/tagixo-primix
pretendtrue/laravel-builder
sawmainek/laravel-scout-tntsearch-driver
tomshaw/laravel-calendar-table
dibakar/laravel-ownership
steadrun/laravel-monitor
labyrinthe/connect-laravel
elmogy/layan
drewdan/sentinel-client
dskripchenko/laravel-llm
fatryst/nuonuo
stevenay/myanfont
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc