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
Ensures Composer autoloader is optimized for production performance
Configuration Caching
Ensures configuration caching is properly configured for each environment
Route Caching
Ensures route caching is properly configured for optimal performance
View Caching
Ensures Blade views are properly compiled and cached for optimal performance
OPcache Enabled
Ensures OPcache is enabled for PHP bytecode caching and performance
Cache & Session Configuration
Cache Driver Configuration
Ensures a proper cache driver is configured for optimal performance
Shared Cache Lock Store
Detects cache lock usage on the default cache store, which can cause locks to be cleared when cache is flushed
Session Driver Configuration
Ensures a proper session driver is configured for scalability and performance
Queue & Background Jobs
Queue Driver Configuration
Ensures a proper queue driver is configured for optimal performance and reliability
Horizon Suggestion
Recommends using Laravel Horizon when Redis queues are configured
Database & Queries
MySQL Single Server Optimization
Ensures MySQL is configured optimally for single-server setups using Unix sockets
Collection Call Optimization
Detects inefficient collection operations that should be performed at the database query level
Assets & Frontend
Asset Minification
Ensures JavaScript and CSS assets are minified in production
Asset Cache Headers
Ensures compiled assets have appropriate cache headers for optimal browser caching
Configuration & Environment
Debug Log Level
Ensures log level is not set to debug in production for optimal performance
Env Calls Outside Config
Detects env() function calls outside configuration files that break when config is cached
Dev Dependencies in Production
Detects if development dependencies are installed in production environment
Unused Global Middleware
Detects global HTTP middleware that is registered but not being used, causing unnecessary overhead
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
php artisan shield:analyze --category=performanceRun Specific Analyzer
php artisan shield:analyze --analyzer=opcache-enabled
php artisan shield:analyze --analyzer=config-caching
php artisan shield:analyze --analyzer=collection-call-optimizationRun Multiple Analyzers
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