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

Phpmnd Laravel Package

povils/phpmnd

PHPMND detects magic numbers in PHP code to improve readability and maintainability. Flags numeric literals that should be constants (0 and 1 ignored by default). Install via Composer and run vendor/bin/phpmnd locally or globally in CI and dev workflows.

View on GitHub
Deep Wiki
Context7

PHP Magic Number Detector

Frequently asked questions about Phpmnd
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.
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.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor