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 Metrics

Php Metrics Laravel Package

halleck45/php-metrics

PhpMetrics analyzes PHP projects and classes, producing a readable HTML report packed with code metrics like cyclomatic complexity, maintainability index, and coupling. Install it as a dev dependency via Composer and run it against any folder to spot risky code and track quality over time.

View on GitHub
Deep Wiki
Context7

Beautiful and understandable static analysis tool for PHP

Frequently asked questions about Php Metrics
How do I install PhpMetrics as a dev dependency in a Laravel project?
Run composer require phpmetrics/phpmetrics --dev from your Laravel project root. The executable is then available at vendor/bin/phpmetrics. Because it is a CLI analysis tool, it belongs in require-dev rather than production dependencies.
Does PhpMetrics support my Laravel and PHP version?
PhpMetrics is not Laravel-specific; it analyzes PHP source files, so the Laravel version is largely irrelevant. What matters is whether the bundled PHP parser supports your exact PHP minor version. Check the current release requirements and validate it against your PHP version before rolling it out in CI.
How do I run PhpMetrics and where does the HTML report go?
Run php ./vendor/bin/phpmetrics --report-html=myreport app/ from your project root. PhpMetrics writes a self-contained HTML report into the specified directory. Open myreport/index.html in a browser to review the project and class metrics.
How do I exclude vendor, storage, and generated Laravel files from the report?
Use a PhpMetrics configuration file, typically .phpmetrics.yml, and pass it with --config. Add exclude rules for vendor/, storage/, bootstrap/cache/, generated migrations, and IDE helper stubs. This keeps the report focused on authored application code rather than framework or generated files.
Can PhpMetrics fail a CI build when complexity thresholds are exceeded?
PhpMetrics is primarily oriented toward visual reporting, so build-breaking thresholds are not its default workflow. You can use the violations report output or parse the JSON/XML output in a wrapper script to enforce limits. Confirm the exact gating behavior before promising a quality gate to your team.
Does PhpMetrics replace PHPStan, Psalm, or PHP_CodeSniffer?
No. PhpMetrics is a complexity and trend-analysis layer, not a correctness or style checker. PHPStan and Psalm focus on type and correctness analysis, PHP_CodeSniffer handles style, and Deptrac can enforce architecture boundaries. Run PhpMetrics alongside those tools rather than using it to displace them.
What metrics does PhpMetrics report for Laravel classes and projects?
PhpMetrics computes class, file, and project-level metrics including cyclomatic complexity, Halstead metrics, maintainability index, CRAP, LCOM, coupling, and comment ratio. It presents them in a readable HTML report and can also emit JSON, XML, and CSV variants. These metrics help identify risky or hard-to-maintain code and track quality trends over time.
Can I get JSON or XML output from PhpMetrics for dashboards and automation?
Yes. PhpMetrics can emit JSON, XML, and CSV variants in addition to the HTML report. That makes it possible to archive results, build dashboards, or parse metrics in a CI wrapper script.
Does PhpMetrics add runtime overhead or dependencies in production?
No. PhpMetrics installs as a Composer dev dependency and has zero runtime footprint in production, with no autoload surface, framework coupling, or service registration. It reads source files and writes report artifacts, so its impact is limited to development and CI.
Is PhpMetrics maintained, and should I pin phpmetrics/phpmetrics in Composer?
PhpMetrics is maintained by Jean-François Lépine under the Halleck45 GitHub organization. The installable Composer package is phpmetrics/phpmetrics, not halleck45/php-metrics. Pin an explicit version and review the changelog before upgrades because report formats and parser support can change between releases.
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