Rasmus Lerdorf's opcache-status script

My Favorite Zend OPcache Status Scripts 2


When I upgraded to PHP 5.5, I also said goodbye to my beloved APC cache (which never let me down) in favor of Zend OPcache, because it’s already part of the PHP package. Back when I used APC, one of my favorite tools was the apc.php script that showed cache status and allowed me to clear the cache right from a web  browser:

APC Status PHP Script

APC Status PHP Script

So after switching over to the updated Zend OPcache, I went on a search for some web-based OPcache status PHP scripts. Following are my three favorites (all the screenshots are from my actual cache status).

Make a Secure Status Directory First

Before downloading any of these scripts and putting them in publicly available directories on your web server, I recommend creating a separate directory on your web server (like http://www.example.com/admin/) and then setting up password authentication to that directory with an .htaccess file. If that’s not something you’ve done before, the Apache Auth docs are here, but you can probably search online for an even easier how-to.

All the examples below assume you’ve set up your secret password protected directory at /www/example.com/htdocs/admin.

OPcache-Status

This great script is written by Rasmus Lerdorf. If the name sounds familiar, it should. He’s the original creator of the PHP scripting language. I love the dynamic charts and the easy to use tabs. But my favorite is hitting the “Visualise Partition” tab. Try it. You’ll dig it.

Rasmus Lerdorf's opcache-status script

Rasmus Lerdorf’s opcache-status script

You can download the script from his opcache-status GitHub by doing:

cd /www/example.com/htdocs/admin
wget https://raw.github.com/rlerdorf/opcache-status/master/opcache.php

OCP – OPcache Control Panel

Written by _CK_, this script will remind you of the phpinfo() output, but with some added twists. The charts at the top of the script are helpful, and drilling down to the file level is easy.

OPC - how can I 'splain it? Let's take it frame by frame, it..

OPC – how can I ‘splain it? Let’s take it frame by frame, it..

Grab it from _CK_’s GitHub Gist collection with:

cd /www/example.com/htdocs/admin
wget https://gist.github.com/ck-on/4959032/raw/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb/ocp.php

 OPcache-GUI

First, it’s straight up impossible for me to read the name of this script without hearing it in my head in the style of Sir Mix-a-lot’s “Swap Meet Louie.” But it’s a great script, brought to us by Andrew Collington, and it’s the best one I’ve found for a quick check of memory usage and hit rate. Just look at the size of those buttons!

OPcache-GUI (clockin' lotsa dollahs!)

OPcache-GUI (clockin’ lotsa dollahs!)

Grab this OPcache status script from Andrew’s GitHub with:

cd /www/example.com/htdocs/admin
wget https://raw.githubusercontent.com/amnuts/opcache-gui/master/index.php -O opcache-gui.php

OpCacheGUI

Not to be confused with the script above with the hyphen, OpCacheGUI is great script I learned about from someone who commented on this article.

OpCacheGui

OpCacheGui

You can grab it on PeeHaa’s GitHub page, and with a couple minutes of easy configuration, you’re up and running. It’s got a great interface, cool animations, and looks great on mobile devices! I’ve added it to my arsenal, and recommend you give it a go!

Memcache Bonus!

One of the things I miss about APC is that in addition to a great opcode cache, it also included a user data cache. Being a jack of all trades is probably what contributed to APC slowly being replaced around the web by the Zend OPcache, but until (or unless) the Zend guys choose to implement a user cache, you’re going to end up using something else if you need a user cache. Because it works with my WordPress cache setup, I’m using Memcached — so as a little extra bonus, I’ve included a management script here for Memcached that looks strangely familiar to the old apc.php output. It comes to us courtesy of Harun Yayli.

memcache.php status script

memcache.php status script

Download it here, direct from Harun’s site.

Enjoy your new-found ability to monitor and manage your Zend OPcache and Memcached!

Got another script that should be on this list? I welcome your suggestions, questions, and comments below!

  • Marvin

    I am using OpCacheGUI https://github.com/PeeHaa/OpCacheGUI to manage my opcache installation. They also will support apcu (the apc replacement) soon according to the open tickets on github.

    • Thanks, Marvin. Great recommendation. I’ve added it to the article above!