Performance Analyzers
18 analyzers identifying bottlenecks and optimization opportunities in Laravel applications.
Overview
Performance analyzers focus on optimizing application speed, reducing resource consumption, and ensuring your Laravel application runs efficiently in production. These analyzers help identify configuration issues, caching problems, inefficient queries, and other performance bottlenecks that can slow down your application.
Key Analyzers
Caching & Optimization
- Composer Autoloader Optimization Analyzer - Ensures Composer autoloader is optimized for production performance
- Configuration Caching Analyzer - Ensures configuration caching is properly configured for each environment
- Route Caching Analyzer - Ensures route caching is properly configured for optimal performance
- View Caching Analyzer - Ensures Blade views are properly compiled and cached for optimal performance
- OPcache Enabled Analyzer - Ensures OPcache is enabled for PHP bytecode caching and performance
Cache & Session Configuration
- Cache Driver Configuration Analyzer - Ensures a proper cache driver is configured for optimal performance
- Shared Cache Lock Store Analyzer - Detects cache lock usage on the default cache store, which can cause locks to be cleared when cache is flushed
- Session Driver Configuration Analyzer - Ensures a proper session driver is configured for scalability and performance
Queue & Background Jobs
- Queue Driver Configuration Analyzer - Ensures a proper queue driver is configured for optimal performance and reliability
- Horizon Suggestion Analyzer - Recommends using Laravel Horizon when Redis queues are configured
Database & Queries
- MySQL Single Server Optimization Analyzer - Ensures MySQL is configured optimally for single-server setups using Unix sockets
- Collection Call Optimization Analyzer - Detects inefficient collection operations that should be performed at the database query level
Assets & Frontend
- Asset Minification Analyzer - Ensures JavaScript and CSS assets are minified in production
- Asset Cache Headers Analyzer - Ensures compiled assets have appropriate cache headers for optimal browser caching
Configuration & Environment
- Debug Log Level Analyzer - Ensures log level is not set to debug in production for optimal performance
- Env Calls Outside Config Analyzer - Detects env() function calls outside configuration files that break when config is cached
- Dev Dependencies in Production Analyzer - Detects if development dependencies are installed in production environment
- Unused Global Middleware Analyzer - Detects global HTTP middleware that is registered but not being used, causing unnecessary overhead on every request
How They Work
Performance analyzers use a combination of:
- Configuration Analysis: Checks Laravel configuration files for optimal settings
- File System Checks: Validates cache files, compiled views, and optimized autoloaders
- Code Analysis: Detects inefficient patterns like collection operations that should be database queries
- Environment Validation: Ensures production environments are properly configured
- Asset Analysis: Checks frontend assets for minification and cache headers
Severity Levels
| Severity | Description | Examples |
|---|---|---|
| Critical | Issues that severely impact performance | Missing OPcache, debug mode in production, no caching enabled |
| High | Issues that significantly slow down the application | Inefficient queries, missing route caching, wrong cache driver |
| Medium | Issues that reduce performance | Unminified assets, unused middleware, collection operations |
| Low | Optimization opportunities | Missing cache headers, suboptimal configuration |
Running Performance Analyzers
Run All Performance Analyzers
bash
php artisan shield:analyze --category=performanceRun Specific Analyzer
bash
php artisan shield:analyze --analyzer=opcache-enabled
php artisan shield:analyze --analyzer=config-caching
php artisan shield:analyze --analyzer=collection-call-optimizationRun Multiple Analyzers
bash
php artisan shield:analyze --analyzer=opcache-enabled,config-caching,route-caching,view-cachingBest Practices
Development
- Run performance analyzers before deploying to production
- Fix Critical and High severity issues immediately
- Use performance analyzers to identify bottlenecks during development
Production Deployment
- Ensure all caching is enabled (config, routes, views)
- Verify OPcache is enabled and configured
- Check that debug mode is disabled
- Validate cache drivers are production-ready (Redis, Memcached)
CI/CD
- Run performance analyzers in staging environment
- Fail builds on Critical performance issues
- Monitor performance metrics over time
Monitoring
- Track performance improvements after fixes
- Monitor cache hit rates
- Measure response times before and after optimizations
Performance Checklist
Before deploying to production, ensure:
- ✅ OPcache is enabled and configured
- ✅ Configuration is cached (
php artisan config:cache) - ✅ Routes are cached (
php artisan route:cache) - ✅ Views are compiled (
php artisan view:cache) - ✅ Autoloader is optimized (
composer install --optimize-autoloader --no-dev) - ✅ Debug mode is disabled (
APP_DEBUG=false) - ✅ Cache driver is production-ready (Redis/Memcached)
- ✅ Session driver is production-ready (Redis/database)
- ✅ Queue driver is configured (Redis/database/SQS)
- ✅ Assets are minified and have cache headers
- ✅ No development dependencies in production
- ✅ No env() calls outside config files
Related Categories
- Security Analyzers - Prevent security vulnerabilities
- Reliability Analyzers - Ensure application stability
- Best Practices Analyzers - Follow Laravel conventions
- Code Quality Analyzers - Maintain code quality standards