Skip to content

Configuration

Create an analyzer.php configuration file:

<?php
use Cline\Analyzer\Config\AnalyzerConfig;
return AnalyzerConfig::make()
->paths([
__DIR__.'/src',
__DIR__.'/tests',
])
->workers(0) // 0 = auto-detect CPU cores
->ignore([
'Illuminate\\*',
'Symfony\\*',
'PHPUnit\\*',
])
->exclude([
'vendor',
'node_modules',
'storage',
]);

Specify directories or individual files to analyze:

$config->paths(['src', 'tests', 'app/Models/User.php']);

Configure parallel processing worker count:

// Auto-detect CPU cores (default behavior when workers = 0)
$config->workers(0);
// Specify exact worker count
$config->workers(4); // Use 4 workers
$config->workers(8); // Use 8 workers

Command-line override:

Terminal window
php artisan analyzer:analyze --workers=auto # Auto-detect
php artisan analyzer:analyze --workers=8 # Use 8 workers

The analyzer automatically detects your CPU core count when workers is set to 0 or 'auto'. This uses:

  • macOS: sysctl -n hw.ncpu
  • Linux: nproc
  • Fallback: 4 cores if detection fails

Skip class references matching patterns:

$config->ignore([
'Illuminate\\*', // All Illuminate classes
'Symfony\\Component\\*', // Symfony components
'Test\\*', // Test namespace
]);

Patterns use fnmatch() syntax:

  • * matches any characters
  • ? matches a single character
  • [abc] matches a, b, or c

Exclude files and directories from being scanned:

$config->exclude([
'vendor', // Skip vendor directory
'node_modules', // Skip node_modules
'storage', // Skip storage directory
'bootstrap/cache', // Skip Laravel cache
'build', // Skip build artifacts
'*.blade.php', // Skip Blade templates
'tests/fixtures/*', // Skip test fixtures
]);

Difference between ignore() and exclude():

  • exclude() - Prevents files/directories from being scanned at all (performance optimization)
  • ignore() - Scans files but skips specific class name patterns during analysis

Exclude patterns support:

  • Simple substring matching: 'vendor' matches any path containing “vendor”
  • Glob patterns: 'tests/fixtures/*' matches any file in tests/fixtures/
  • File patterns: '*.blade.php' matches all Blade template files

Command-line override:

Terminal window
php artisan analyzer:analyze --exclude=vendor --exclude=storage

All configuration methods return a new instance, allowing fluent chaining:

$config = AnalyzerConfig::make()
->paths(['src'])
->workers(2)
->ignore(['Test\\*'])
->exclude(['vendor', 'storage'])
->pathResolver(new CustomPathResolver());

Load from a file:

$config = require __DIR__.'/analyzer.php';
$analyzer = new Analyzer($config);

Configure translation key validation:

$config->analysisResolver(new TranslationAnalysisResolver(
langPath: base_path('lang'),
locales: ['en', 'es', 'fr'],
reportDynamic: true,
vendorPath: base_path('vendor/*/lang'),
ignore: ['debug.*', 'temp.*'],
includePatterns: ['validation.*', 'auth.*']
));
OptionDescription
langPathPath to lang directory
localesArray of locales to validate
reportDynamicReport dynamic keys as warnings
vendorPathPath to vendor translations
ignorePatterns to ignore
includePatternsOnly validate these patterns

Configure route name validation:

$config->analysisResolver(new RouteAnalysisResolver(
routesPath: base_path('routes'),
cacheRoutes: true,
cacheTtl: 3600,
reportDynamic: true,
includePatterns: ['admin.*', 'api.*'],
ignorePatterns: ['debug.*'],
app: app()
));
OptionDescription
routesPathPath to routes directory
cacheRoutesEnable route caching
cacheTtlCache TTL in seconds
reportDynamicReport dynamic route names as warnings
includePatternsOnly validate these patterns
ignorePatternsPatterns to ignore
appLaravel application instance