diff --git a/README.md b/README.md index abbd452..b69504a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,19 @@ -opcache-gui -=========== +# opcache-gui A simple, responsive interface for Zend OPcache information showing the statistics, settings and cached files. + +### overview + +The overview will show you all the core information. From here you'll be able to see what host and platform you're running on, what version of OPcache you're using, when it was last reset, the functions that are available, all the directives and all the statistics associated with the OPcache (number of hits, memory used, free and wasted memory, etc.) + +### file usage + +All the files currently in the cache are listed here with their associated statistics. You can filter the results very easily to key in on the particular scripts you're looking for, and you can optionally set levels of the path to be hidden (handy if they all share a common root and you don't want that displayed). + +### reset cache + +There is an option to reset the whole cache and you can also optionally force individual files to become invalidated so they will be cached again. (NB: *Apparently, some version of PHP may cause a segmentation fault when using opcache_invalidate, so there is a setting in the gui script if you want to turn off the invalidate links.*) + +# License + +MIT: http://acollington.mit-license.org/ diff --git a/index.php b/index.php index 06e91ee..d99f12e 100644 --- a/index.php +++ b/index.php @@ -1,15 +1,27 @@ 2 + 'compress_path_threshold' => 2, + 'used_memory_percentage_high_threshold' => 80, + 'used_memory_percentage_mid_threshold' => 60, + 'allow_invalidate' => true ); -$validPages = array('overview', 'files', 'reset'); +$validPages = array('overview', 'files', 'reset', 'invalidate'); $page = (empty($_GET['page']) || !in_array($_GET['page'], $validPages) ? 'overview' : strtolower($_GET['page']) @@ -18,10 +30,23 @@ $page = (empty($_GET['page']) || !in_array($_GET['page'], $validPages) if ($page == 'reset') { opcache_reset(); header('Location: ?page=overview'); + exit; +} + +if ($page == 'invalidate') { + $file = (isset($_GET['file']) ? trim($_GET['file']) : null); + if (!$settings['allow_invalidate'] || !function_exists('opcache_invalidate') || empty($file)) { + header('Location: ?page=files&error=1'); + exit; + } + $success = (int)opcache_invalidate(urldecode($file), true); + header("Location: ?page=files&success={$success}"); + exit; } $opcache_config = opcache_get_configuration(); $opcache_status = opcache_get_status(); +$opcache_funcs = get_extension_funcs('Zend OPcache'); if (!empty($opcache_status['scripts'])) { uasort($opcache_status['scripts'], function($a, $b) { @@ -74,9 +99,9 @@ $data = array_merge( ); $threshold = ''; -if ($data['used_memory_percentage'] >= 80) { +if ($data['used_memory_percentage'] >= $settings['used_memory_percentage_high_threshold']) { $threshold = ' high'; -} elseif ($data['used_memory_percentage'] >= 60) { +} elseif ($data['used_memory_percentage'] >= $settings['used_memory_percentage_mid_threshold']) { $threshold = ' mid'; } @@ -130,10 +155,12 @@ $host = (function_exists('gethostname') table tr.odd { background-color: #EFFEFF; } table tr.even { background-color: #E0ECEF; } table tr.highlight { background-color: #61C4DF; } + td.pathname p { margin-bottom: 0.25em; } .wsnw { white-space: nowrap; } .low{color:#000000;} .mid{color:#550000;} .high{color:#FF0000;} + .invalid{color:#FF4545;} span.showmore span.button { display: inline-block; margin-right: 5px; @@ -177,46 +204,6 @@ $host = (function_exists('gethostname') #frmFilter{width:99% !important;} } -
@@ -295,13 +282,49 @@ $host = (function_exists('gethostname')Available functions |
---|
+ ?>
+ + Force file invalidation +
hits: ,
memory:
last used:
+
+
has been invalidated
+