aping/laravel-opcache-gui
Laravel Opcache GUI for Laravel apps. Adds a simple web page to view PHP OPCache status and configuration. Install via Composer, register the service provider, and add a route to access the dashboard (e.g., /opcache). Flush support planned.
Installation:
composer require aping/laravel-opcache-gui
Publish the configuration file (if needed):
php artisan vendor:publish --provider="Aping\LaravelOpcacheGui\OpcacheGuiServiceProvider" --tag="config"
Configuration:
Edit config/opcache-gui.php to set:
enabled (default: true)route (default: /opcache-gui)middleware (e.g., ['web'] or ['auth'] for restricted access)cache_id (optional, if using multiple OPcache instances)First Use Case:
Access the GUI via the configured route (e.g., /opcache-gui). No additional setup is required—it automatically integrates with Laravel’s OPcache configuration.
Monitoring OPcache: Use the GUI to inspect:
Debugging Performance Issues:
Integration with CI/CD:
use Aping\LaravelOpcacheGui\Facades\OpcacheGui;
public function checkOpcache()
{
$stats = OpcacheGui::stats();
if ($stats['hit_rate'] < 0.75) {
throw new \RuntimeException('OPcache hit rate too low!');
}
}
Restricting Access:
auth) in the config:
'middleware' => ['web', 'auth'],
'enabled' => env('APP_ENV') !== 'production',
php artisan vendor:publish --provider="Aping\LaravelOpcacheGui\OpcacheGuiServiceProvider" --tag="views"
OPcache Disabled:
php.ini (opcache.enable=0).sudo service php-fpm restart).Permission Issues:
opcache.file_cache, ensure the directory (opcache.file_cache=/tmp) is writable by the PHP process.opcache.error_log for file permission errors.Multiple PHP Versions:
'cache_id' => 'php-fpm',
in the config.Laravel Caching Conflicts:
No Data Displayed:
php -m | grep opcache).storage/logs/laravel.log) for OPcache-related errors.Slow GUI Response:
opcache_get_status(). High traffic may cause delays.$stats = Cache::remember('opcache_stats', now()->addMinutes(5), function () {
return opcache_get_status();
});
Custom Metrics:
resources/views/vendor/opcache-gui/index.blade.php view and include additional logic:
@inject('opcache', 'Aping\LaravelOpcacheGui\Facades\OpcacheGui')
<div class="custom-metrics">
{{ $opcache->customMetric() }}
</div>
Artisan Commands:
use Aping\LaravelOpcacheGui\Facades\OpcacheGui;
class ResetOpcacheCommand extends Command
{
public function handle()
{
OpcacheGui::reset();
$this->info('OPcache reset successfully.');
}
}
Event Listeners:
use Aping\LaravelOpcacheGui\Events\OpcacheUpdated;
OpcacheUpdated::listen(function ($event) {
Log::info('OPcache updated at ' . now());
});
opcache.revalidate_freq:
2) forces frequent script revalidation, reducing cache efficiency.180 (3 minutes) for most applications.opcache.max_accelerated_files:
10000 (adjust based on your app’s size).Environment-Specific Settings:
config/opcache-gui.php:
'route' => env('OPACHE_GUI_ROUTE', '/opcache-gui'),
How can I help you explore Laravel packages today?