- How do I install PHPMND for Laravel projects?
- Run `composer require --dev povils/phpmnd` in your Laravel project directory. This installs it as a dev dependency, allowing you to execute it via `vendor/bin/phpmnd` without affecting production.
- Does PHPMND work with Laravel 10 and PHP 8.5?
- Yes, PHPMND v3.6.1+ fully supports Laravel 10 (PHP 8.2+) and PHP 8.5. It’s tested with modern Laravel ecosystems, including Symfony 8 components like `symfony/http-client`.
- Can I exclude certain files or directories from scanning?
- Absolutely. Use a `.phpmnd.yml` config file to define exclusions. For example, exclude `vendor/` or Symfony-integrated paths like `app/Symfony/` by adding `exclude: [vendor/, app/Symfony/]`.
- Will PHPMND flag constants or typed class constants (e.g., `public const int BAR = 42`)?
- No, it won’t flag constants. However, PHP 8.5’s typed class constants (e.g., `class Foo { public const int BAR = 42; }`) are safe—just ensure they’re not mistaken for magic numbers by adjusting `.phpmnd.yml` if needed.
- How do I integrate PHPMND into Laravel’s CI pipeline?
- Add a step to your CI (e.g., GitHub Actions) like this: `vendor/bin/phpmnd --config=.phpmnd.yml --format=github .`. For Laravel 10+, specify `PHP_VERSION: '8.2'` or `8.5` in your CI environment.
- Does PHPMND support Symfony components in Laravel apps?
- Yes, PHPMND now works seamlessly with Symfony 8+ components in Laravel. If you use packages like `symfony/mailer` or `symfony/http-client`, scan them alongside your Laravel code or exclude them via `.phpmnd.yml`.
- What’s the best way to handle false positives in Laravel’s business logic?
- Start with the default config, then refine `.phpmnd.yml` to whitelist known non-magic numbers (e.g., `whitelist: [2, 3]`). For Laravel-specific cases, exclude paths like `app/Config/` if they contain hard-coded but intentional values.
- Can I use PHPMND alongside PHPStan or Psalm?
- Yes, PHPMND is complementary. Run it in your CI before PHPStan/Psalm for early detection of magic numbers. Example workflow: `phpmnd` → `phpstan` → `psalm`. No conflicts exist between these tools.
- How do I configure PHPMND to ignore specific numeric literals?
- Edit `.phpmnd.yml` and add a `whitelist` section. For example, to ignore `2` and `3` globally: `whitelist: [2, 3]`. For Laravel, you might also exclude `config/` values like `whitelist: [259200, 3600]` for cache durations.
- What’s the performance impact of running PHPMND in CI?
- Minimal. PHPMND is a lightweight static analyzer with no runtime overhead. On average, it scans 1,000+ files in under 5 seconds in CI. For large Laravel apps, limit scans to `app/` and `config/` directories to optimize speed.