Weave Code
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
## Technical Evaluation

### **Architecture Fit**
- **Purpose Alignment**: The package remains a **strong fit** for enforcing architectural constraints in Laravel/PHP projects, particularly for detecting coupling violations (e.g., circular dependencies, layer violations). The focus on **customizable rules** aligns well with Laravel’s dependency injection and service container patterns, though Laravel-specific edge cases (e.g., facades, dynamic method calls) may still require tuning.
- **Laravel-Specific Gaps**: No changes to the core architectural fit, but the **Symfony 7 compatibility fix** (PR #74) suggests potential relevance for Laravel projects using Symfony components (e.g., Symfony HTTP Client, Mailer). This could improve integration with Laravel’s **HTTP clients** or **mail services** if they are flagged as coupling violations.
- **Experimental Risk**: Still labeled "experimental," but the **PHP 8.2 compatibility** (PR #73) reduces risk for Laravel 10+ projects (which support PHP 8.2). Validate if the package handles Laravel’s **magic methods** (e.g., `Route::get()`, `Model::find()`) or **dynamic facades** without false positives.

### **Integration Feasibility**
- **Static Analysis Hook**: Integration into **CI/CD pipelines** (e.g., GitHub Actions) remains feasible, with the added benefit of **Symfony 7 compatibility** potentially reducing conflicts in projects using Symfony components alongside Laravel.
- **IDE/Editor Plugins**: No direct changes, but the **PHP 8.2 support** opens doors for better IDE plugin compatibility (e.g., PHPStorm’s PHP 8.2+ features).
- **Rule Customization**: Custom rules remain the core strength, but the **Symfony 7 fix** may imply better handling of **Symfony-based Laravel services** (e.g., `Symfony\Contracts\HttpClient`). Test if this reduces false positives for **HTTP clients** or **mailers** in Laravel.

### **Technical Risk**
- **False Positives/Negatives**:
  - **Symfony 7 Fix**: May reduce false positives for projects using Symfony components (e.g., `HttpClient`, `Mailer`). However, **Laravel’s facades** (e.g., `Cache::get()`) or **dynamic method calls** (e.g., `$request->input()`) may still trigger issues. Benchmark against a **Laravel + Symfony component** codebase (e.g., a project using `symfony/http-client`).
  - **PHP 8.2 Compatibility**: Laravel 10+ projects can now use this without PHP version conflicts, but **backward compatibility** with older Laravel versions (e.g., 9.x) remains untested.
- **Performance Overhead**: No changes to performance, but the **Symfony 7 fix** might introduce minor overhead. Compare runtime against **PHPStan/Psalm** in CI pipelines.
- **Dependency Conflicts**: The **Symfony 7 compatibility** reduces risks for projects using Symfony packages, but ensure no conflicts with Laravel’s **Symfony bridge** (e.g., `symfony/console` for Artisan).
- **Tooling Ecosystem**: Still lacks **Laravel-specific documentation**, but the **PHP 8.2/Symfony 7 updates** suggest growing maturity. Check if the package now includes **examples for Laravel integration**.

### **Key Questions**
1. **Symfony Component Handling**: Does the **Symfony 7 fix** properly handle Laravel’s use of Symfony components (e.g., `HttpClient`, `Mailer`) without false positives?
2. **Facade and Dynamic Method Support**: Are there new **rule exceptions** for Laravel’s **facades** (e.g., `Cache`, `Log`) or **dynamic calls** (e.g., `$request->input()`)?
3. **PHP 8.2 Features**: Does the package leverage **PHP 8.2 attributes** or **enums** that could conflict with Laravel’s use of these features?
4. **Backward Compatibility**: Will this version **break Laravel 9.x** projects (PHP 8.1) due to PHP 8.2 dependencies?
5. **Rule Granularity for Symfony**: Can rules distinguish between **Laravel-specific coupling** (e.g., Controller → Service) and **Symfony-related coupling** (e.g., Service → Symfony HttpClient)?

---

## Integration Approach

### **Stack Fit**
- **PHP/Laravel Compatibility**:
  - **PHP 8.2 Support**: Now compatible with **Laravel 10+**, reducing version conflicts. For **Laravel 9.x**, test if the package can be used with PHP 8.1 (may require downgrading dependencies).
  - **Symfony Component Synergy**: Better integration with Laravel projects using **Symfony HTTP Client**, **Mailer**, or **Console** components. May reduce false positives for these cases.
- **Toolchain Synergy**:
  - **Static Analysis**: Pair with **PHPStan/Psalm** for broader coverage, but prioritize this package for **coupling-specific** rules.
  - **CI/CD**: Integrate as a **pre-merge check** in GitHub Actions, leveraging the **Symfony 7 fix** to avoid conflicts in hybrid Laravel/Symfony projects.
  - **Testing**: Use alongside **PestPHP** to ensure coupling rules don’t break existing test suites.
- **Alternative Tools**: Still compare against:
  - **PHPStan’s `no-unused-services`** (for DI issues).
  - **Architecture Tests** (for broader structural checks).

### **Migration Path**
1. **Pilot Phase**:
   - Test on a **Laravel 10+ project** using Symfony components (e.g., `HttpClient`) to validate the **Symfony 7 fix**.
   - Run with **default rules** to identify false positives/negatives, then **tune rules** for Laravel-specific patterns (e.g., facades, dynamic calls).
2. **Incremental Rollout**:
   - Start with **non-critical modules** (e.g., admin panels, APIs).
   - Use `--allow-failures` to ease adoption, then enforce in CI.
3. **CI Gating**:
   - Initially **warn** on violations, then **block merges** after stakeholder approval.
4. **Documentation**:
   - Add a **Laravel-specific runbook** covering:
     - How to **exclude facades** from coupling rules.
     - Handling **Symfony components** (e.g., `HttpClient`).
     - Resolving **dynamic method violations** (e.g., `$request->input()`).

### **Compatibility**
- **Laravel-Specific Adjustments**:
  - **Symfony Components**: Update rules to **exclude allowed Symfony services** (e.g., `HttpClient`, `Mailer`) if they are intentionally used.
  - **Facades**: Add **exceptions for Laravel facades** (e.g., `Cache`, `Log`) or treat them as coupling (team decision).
  - **Dynamic Code**: Test if the package now **ignores dynamic calls** (e.g., Blade directives, magic methods) or if new rules are needed.
- **Third-Party Packages**:
  - Test with **Laravel + Symfony packages** (e.g., Spatie’s `laravel-http-client`, which uses Symfony `HttpClient`).
  - Ensure no conflicts with **Laravel’s Symfony bridge** (e.g., `symfony/console` for Artisan).
- **PHP Extensions**:
  - No changes expected, but verify **Xdebug/OPcache** compatibility in PHP 8.2.

### **Sequencing**
1. **Phase 1: Discovery**
   - Run on a **Laravel 10+ project** with Symfony components to validate the **Symfony 7 fix**.
   - Identify **false positives** (e.g., Symfony `HttpClient` usage) and adjust rules.
2. **Phase 2: Rule Refinement**
   - Customize rules for:
     - **Laravel facades** (exclude or flag).
     - **Symfony components** (exclude if intentional).
     - **Dynamic calls** (e.g., `$request->input()`).
3. **Phase 3: Enforcement**
   - Integrate into **CI/CD** with **warn → fail** policy.
   - Use **pre-commit hooks** for local feedback.
4. **Phase 4: Optimization**
   - Monitor **false positive rates** and refine rules.
   - Explore **IDE plugins** for real-time coupling feedback.

---

## Operational Impact

### **Maintenance**
- **Rule Updates**:
  - **Symfony 7 Fix**: May require **rule adjustments** for Symfony component usage in Laravel.
  - **PHP 8.2 Features**: Monitor if the package introduces **new attributes/enums** that conflict with Laravel’s usage.
- **Dependency Updates**:
  - **Symfony 7 Compatibility**: Reduces risks for projects using Symfony packages, but ensure no **Laravel-Symfony version conflicts**.
  - **PHP 8.2**: May require **forking** if the package drops PHP 8.1 support.
- **Tooling Drift**:
  - If the package **stagnates**, consider forking or migrating to alternatives (e.g., custom static analysis scripts).

### **Support**
- **Developer Onboarding**:
  - Train teams on:
    - **Symfony component exceptions** (e.g., "It’s okay for `PaymentService` to use `HttpClient`").
    - **Facade handling** (e.g
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.
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager