New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

elcobvg/laravel-opcache

Custom OPcache Cache Driver for Laravel. Faster than Redis or memcached.
433,621 43

Larablocks Analysis

elcobvg/laravel-opcache works with any PHP project: the latest release (0.5.0, Nov 28, 2021) doesn't depend on Laravel.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • No release in the last 12 months (last: Nov 28, 2021)
  • 21,795 downloads a month (at least 10,000)
  • 43 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: Nov 28, 2021.
  • No releases in the last 12 months.
  • First released: Nov 29, 2017.
  • Monthly downloads: 21,795, up 75% from six months ago.
  • 5 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 1, 2026.

Install
composer require elcobvg/laravel-opcache
Latest Version:0.5.0
PHP:>=7.0.0
License:MIT
Last Updated:Nov 28, 2021
Links: GitHub  ·  Packagist
Maintainer: elcobvg

laravel-opcache Build Status

Custom OPcache Cache Driver for Laravel. Faster than Redis, Memcache or APC.

This package adds a cache driver to your Laravel project that uses PHP engine’s in-memory file caching (OPcache) to cache application data.

This method is faster than Redis, Memcache, APC, and other PHP caching solutions because all those solutions must serialize and unserialize objects. By storing PHP objects in file cache memory across requests, this driver can avoid serialization completely!

Installation

Require this package with composer.

composer require elcobvg/laravel-opcache

Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

If you don't use auto-discovery or Laravel version 5.4 or older, add the ServiceProvider to the providers array in config/app.php

ElcoBvg\Opcache\ServiceProvider::class,

Then, make sure you add the driver option to the stores array in config/cache.php

    'opcache' => [
        'driver' => 'opcache',
    ],

And enable the driver in your .env file or in config/cache.php

OPcache configuration

OPcache can only be compiled as a shared extension. You must compile PHP with the --enable-opcache option for OPcache to be available.

OPcache must be enabled and configured in your php.ini. Look for the section starting with [OPcache] and enter the desired values. The more memory you can assign to OPcache, the faster your cache will be. The opcache.max_accelerated_files value should be high enough to hold all objects that need to be cached.

Since all PHP files will be cached with OPcache, it is not advisable to use it in a development environment, so only enable it in production. Alternatively, you can exclude PHP files from being cached by specifying a blacklist file with the opcache.blacklist_filename option.

  opcache.enable=1
  opcache.memory_consumption=512
  opcache.interned_strings_buffer=64
  opcache.max_accelerated_files=32500
  opcache.validate_timestamps=1
  opcache.save_comments=1
  opcache.revalidate_freq=60
  opcache.fast_shutdown=1
  opcache.enable_cli=1

Graceful degradation: when OPcache is not enabled or installed, or memory is insufficient, this driver will still work but will read from the cached files instead of from memory. Since there's no unserialization required, it will still be faster than a regular file cache driver.

Caching Eloquent models

Depending on how you've configured caching in your project, you may want to cache full Eloquent models. If so, base your model classes on ElcoBvg\Opcache\Model instead of the regular Eloquent base model class, so they can be retrieved correctly from cache.

References

Related Packages

swaty/laravel-fallback-cache

Allow Laravel cache connections to fallback to more stable drivers.

3,047 1
vansteen/laravel-mongodb-cache

A MongoDB cache driver for Laravel 4 using the Laravel MongoDB package jensseger...

2,825 4
demian/laravel-cache-rethinkdb

RethinkDB Cache Driver for Laravel 5

22 1
bunkuris/has-cache

HasCache trait for Laravel models with cache key managers

3,704 0
silber/page-cache

Caches responses as static files on disk for lightning fast page loads.

537,204 1,260

Version History

Version Released PHP License
0.5.0 >=7.0.0 MIT
0.4.1 >=7.0.0 MIT
v0.4.0 >=7.0.0 MIT
0.3.1 >=7.1.3 MIT
0.3.0 >=7.0 MIT