laravel-opcache

Artisan commands and a facade to clear, inspect, and pre-compile PHP OPcache in Laravel apps.

Library
Composer
v4.0.2
1,364stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
48/100Fair
Development Activity0
Maintenance32
Community60
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
77/100Good
Architecture76
Code Quality76
Innovation66
Learning Curve88

laravel-opcache (appstract/laravel-opcache) is a Laravel package that adds a set of Artisan commands for working with PHP OPcache, the opcode cache that speeds up PHP execution. It lets you clear the cache, view its configuration and status, and pre-compile your application’s code from the command line.

The package registers a service provider, config file, HTTP routes, and a facade, so you can manage OPcache both via Artisan (opcache:clear, opcache:config, opcache:status, opcache:compile) and programmatically through the OPcache facade. It is a lightweight production-performance helper for Laravel 7 and newer.

What You Get

  • Artisan commands: opcache:clear, opcache:config, opcache:status, and opcache:compile
  • An OPcache facade for programmatic clearing and management from your code
  • A publishable config file, including a configurable OPCACHE_URL for load-balanced setups
  • HTTP routes and middleware that back the OPcache operations

Common Use Cases

  • Clearing OPcache automatically as part of a deployment pipeline
  • Pre-compiling application code to warm OPcache after a release
  • Inspecting OPcache status and configuration to tune production performance

Under The Hood

Architecture - The package wires into Laravel through OpcacheServiceProvider, which binds an OpcacheClass singleton (exposed via OpcacheFacade), registers the config file, and loads HTTP routes (src/Http/routes.php) plus a request middleware. Four console commands under src/Commands (Clear, Config, Status, Compile) call an internal HTTP endpoint (OpcacheController) so operations run in the web server’s PHP-FPM process where OPcache actually lives, rather than the CLI process. CreatesRequest.php and the Http/Middleware guard construct and authorize those internal calls.

Tech Stack - PHP targeting Laravel 7+, packaged via Composer (composer.json) with PHPUnit for tests. It relies on PHP’s native opcache_* functions and Laravel’s console, routing, and facade subsystems.

Code Quality - The codebase is small and conventional for a Laravel package, with a clear split between commands, HTTP layer, and the core Opcache class, and a tests/ suite plus phpunit.xml.dist. The clever detail is routing cache operations over HTTP so they hit the FPM worker’s opcode cache rather than the separate CLI SAPI.

API Design - Usage is nearly zero-friction: composer require, then run opcache:clear/status/config/compile, or call OPcache::clear() from code. Config is publishable and driven by APP_URL/OPCACHE_URL env values. The concepts are minimal, giving it a very shallow learning curve for any Laravel developer.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search