Getting Started
Installation
Section titled “Installation”Install via Composer:
composer require cline/analyzerThe service provider will be automatically registered via Laravel’s package discovery.
What is Analyzer?
Section titled “What is Analyzer?”Analyzer is a configurable parallel PHP code analyzer that validates references in your codebase. It supports:
- Class References - Validate that all referenced classes exist
- Translation Keys - Validate
trans(),__(), andLang::get()calls against language files - Route Names - Validate
route()andRoute::has()calls against registered routes - Parallel Processing - Analyze files concurrently with auto-detected CPU cores
- AI Agent Mode - Generate XML prompts for automated fixing with parallel AI agents
- Laravel Prompts UI - Beautiful terminal reporting with progress and statistics
Quick Start
Section titled “Quick Start”Artisan Command (Recommended)
Section titled “Artisan Command (Recommended)”# Analyze default paths (app, tests)php artisan analyzer:analyze
# Analyze specific pathsphp artisan analyzer:analyze app/Models app/Services
# Enable parallel processing with auto-detected coresphp artisan analyzer:analyze --workers=auto
# Analyze translation keysphp artisan analyzer:analyze --lang
# Analyze route namesphp artisan analyzer:analyze --route
# AI agent mode for automated fixingphp artisan analyzer:analyze --agentProgrammatic Usage
Section titled “Programmatic Usage”<?php
use Cline\Analyzer\Analyzer;use Cline\Analyzer\Config\AnalyzerConfig;
$config = AnalyzerConfig::make() ->paths(['app', 'tests']) ->workers(0) // 0 = auto-detect CPU cores ->ignore(['Illuminate\\*']) ->exclude(['vendor', 'storage']);
$analyzer = new Analyzer($config);$results = $analyzer->analyze();
exit($analyzer->hasFailures($results) ? 1 : 0);Configuration File
Section titled “Configuration File”Publish the configuration:
php artisan vendor:publish --tag=analyzer-configThis creates analyzer.php in your project root:
<?php
use Cline\Analyzer\Config\AnalyzerConfig;
return AnalyzerConfig::make() ->paths(['app', 'tests']) ->workers(0) // 0 = auto-detect CPU cores ->ignore(['Illuminate\\*', 'Symfony\\*']) ->exclude(['vendor', 'node_modules', 'storage']);Output Modes
Section titled “Output Modes”Human-Readable Output (Default)
Section titled “Human-Readable Output (Default)”The analyzer uses Laravel Prompts for beautiful terminal output with:
- Progress indicators during analysis
- Summary statistics (total files, missing references, top broken namespaces)
- Detailed failure reports with tables
- Color-coded messages for easy scanning
AI Agent Mode
Section titled “AI Agent Mode”Use --agent flag for XML-structured orchestration prompts:
php artisan analyzer:analyze --agentOutputs XML with:
- Analysis summary
- Parallel agent assignments grouped by namespace
- Specific fix instructions for each agent
- Sequential fallback strategy
Perfect for spawning multiple AI agents to fix issues in parallel.
Exit Codes
Section titled “Exit Codes”0: All references are valid1: Missing references found
Next Steps
Section titled “Next Steps”- Configuration - Learn all configuration options
- Parallel Processing - Configure worker count and memory usage
- Custom Resolvers - Implement custom resolution logic
- Examples - CI/CD integration, pre-commit hooks, and more