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

Analyzer Laravel Package

graham-campbell/analyzer

Analyzer is a PHP tool by Graham Campbell that scans your code/tests to verify referenced classes actually exist, catching typos and broken imports early. Requires PHP 8.1–8.5 and supports PHPUnit 10–13 (v5.1).

View on GitHub
Deep Wiki
Context7

Checks if referenced classes really exist.

Frequently asked questions about Analyzer
How do I install Analyzer in a Laravel project?
Run `composer require --dev graham-campbell/analyzer` to install it as a dev dependency. Ensure your project uses PHP 8.1–8.5 and PHPUnit 10–13 (default in Laravel 9+). No additional Laravel-specific setup is required.
Does Analyzer work with Laravel 8?
No, Analyzer v5.1+ requires PHP 8.1+ and PHPUnit 10–13, which aligns with Laravel 9+. For Laravel 8, use v4.x of the package, which supports PHPUnit 7–9, but check compatibility with your PHP version first.
Can I integrate Analyzer into my CI pipeline?
Yes, add it to your CI workflow by running `./vendor/bin/phpunit` with the Analyzer extension enabled in `phpunit.xml`. Failures will block builds if misconfigured classes are found, making it ideal for pre-deployment checks.
What types of class references does Analyzer validate?
Analyzer checks for valid class references in your code, including PHPDoc annotations (`@method`, `@property`, `@var`), Laravel service providers (e.g., `bind()` calls), middleware, and event handlers. It does not validate method signatures or return types.
How do I exclude specific files or classes from analysis?
Use the `getIgnored()` method in your test configuration to exclude files or classes. For example, ignore dynamic classes or legacy code by adding them to the whitelist. This helps avoid false positives in complex projects.
Will Analyzer slow down my local development?
No, Analyzer is designed for CI/CD use. Run it only in your pipeline or via custom scripts to avoid performance overhead. For local testing, use the `shouldAnalyzeFile()` method to limit checks to critical paths.
Does Analyzer support PHPDoc validation for OpenAPI/Swagger?
Yes, Analyzer validates PHPDoc annotations, which are critical for OpenAPI/Swagger documentation. It ensures `@method`, `@property`, and `@var` tags reference real classes, improving API reliability and IDE tooling (e.g., PhpStorm, VSCode).
What alternatives exist for class reference validation in Laravel?
Alternatives include PHPStan (for static analysis) and Psalm (for type checking), but they focus on broader validation. Analyzer specializes in class existence checks, making it lighter and more targeted for Laravel’s dependency patterns like service providers and facades.
How do I configure Analyzer to fail only on critical errors?
Use the `setStrictMode(false)` option to treat missing classes as warnings instead of failures. This is useful during migration phases or for non-critical paths. Combine with `getIgnored()` to fine-tune behavior.
Can Analyzer detect issues in Laravel migrations or factories?
Yes, but exclude them by default using `shouldAnalyzeFile()` to avoid false positives. Migrations and factories often reference dynamic classes (e.g., timestamps, soft deletes) that may not need runtime validation.
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony