- How do I install cmgmyr/phploc for a Laravel project?
- Install it as a development dependency with composer require --dev cmgmyr/phploc, then run it via vendor/bin/phploc. Alternatively, install it globally with composer global install cmgmyr/phploc so the phploc binary is available on your PATH anywhere. Because it has no database or external service dependencies, no further setup or configuration is required.
- What metrics does phploc report?
- phploc reports size metrics such as lines of code (LOC), comment lines (CLOC), non-comment lines (NCLOC), and logical lines of code (LLOC). It also breaks down cyclomatic complexity per class, method, and LLOC, along with dependencies like global accesses, attribute accesses, and method calls. Structure metrics cover namespaces, interfaces, traits, and classes, including average, minimum, and maximum class and method lengths.
- Does phploc integrate with Laravel Artisan?
- There is no native Laravel service provider or facade, so you do not get an out-of-the-box artisan command. phploc is a standalone CLI tool that you run directly against a directory, which fits naturally alongside Artisan-based workflows. If you want artisan phploc, the usual approach is a thin custom Artisan command that shells out to the phploc binary.
- Which PHP and Laravel versions does cmgmyr/phploc support?
- The package targets PHP 7.4 through 8.0, which aligns with Laravel 8 and later applications running on those PHP versions. Because it is a CLI tool that parses PHP source files, it does not need to boot your framework at all. Check the composer.json constraints before installing if your project runs on a newer PHP major version.
- How do I exclude the vendor directory and other paths from analysis?
- Use the --exclude option to skip directories such as vendor/, node_modules/, and storage/ when running phploc on your project root. Laravel's vendor directory is typically the biggest source of noise in the metrics, so excluding it is usually the first adjustment developers make. You can pass multiple exclude patterns to keep the report focused on app/, routes/, database/, and tests/.
- Can phploc be used in a CI/CD pipeline as a quality gate?
- Yes, phploc is commonly wired into GitHub Actions, GitLab CI, or Jenkins as a metrics step because it runs quickly and has no infrastructure requirements. Since the output is plain text, your pipeline script needs to parse the values you care about, such as average cyclomatic complexity or maximum class length, and fail the build when a threshold is exceeded. Validate the parsing and thresholds on a staging copy first to avoid false positives or negatives in automated runs.
- Can I store phploc results in a database or dashboard?
- phploc has no JSON or API output mode, so results are only printed to the terminal as formatted text. To persist metrics you need to capture stdout and parse the report with a small script or regex before writing it to a database, SonarQube, or a custom dashboard. This is the main limitation to plan around if you want historical trend tracking.
- How does phploc perform on very large Laravel applications?
- phploc is a low-overhead, file-parsing tool with no database connections or heavy dependencies, so it generally completes in seconds even on sizeable codebases. There is no built-in parallel processing, so runtime scales with the number of files and their size. For projects with tens of thousands of files, exclude vendor/ and other non-application paths and benchmark on a copy before adding it to a long-running pipeline.
- Is cmgmyr/phploc safe to use, given it is a fork of sebastianbergmann/phploc?
- cmgmyr/phploc is a fork of the well-known sebastianbergmann/phploc and should be treated like any low-adoption dependency: review it before relying on it. Pin an exact version in composer.json, keep it in require-dev so it never ships to production, and validate the output against a known project. If the fork becomes unreliable, you can fall back to the original sebastianbergmann/phploc package, which shares the same CLI.
- Does phploc analyze Blade templates, Eloquent models, or other Laravel-specific constructs?
- phploc analyzes PHP source files only, so Blade templates are not measured and no Laravel-specific features such as Eloquent relationship analysis are included. It does correctly parse autoloaded namespaced classes, including Illuminate namespaces, provided it is pointed at the right directories. For template complexity or framework-aware metrics you will need a complementary tool.