Skip to content

Commit a70fe57

Browse files
amnutsmatthiasstrakacpeel
authored
New release (#124)
* Add German language support (#123) * JIT isn't available in PHP <8.0 (#120) * Updated to latest js libraries * Updates for newer sass package * Fixes #122 * Fixes #118 * Tweaked readme --------- Co-authored-by: Matthias Straka <59084281+matthiasstraka@users.noreply.github.com> Co-authored-by: Casey Peel <cpeel@users.noreply.github.com>
1 parent 4ad9866 commit a70fe57

File tree

13 files changed

+984
-2691
lines changed

13 files changed

+984
-2691
lines changed

README.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# opcache-gui
22

3-
A clean and responsive interface for Zend OPcache information, showing statistics, settings and cached files, and providing a real-time update for the information.
3+
A clean and responsive interface for Zend OPcache information, showing statistics, settings, cached files, and providing a real-time update for the information.
44

55
This interface uses ReactJS and Axios and is for modern browsers, and requires a minimum of PHP 7.1.
66

@@ -22,13 +22,13 @@ There are two ways to getting started using this gui:
2222

2323
#### Copy/clone this repo
2424

25-
The easiest way to start using the opcache-gui is to clone this repo, or simply copy/paste/download the `index.php` file to a location which your web server can load. Then point your browser to that location, such as `https://www.example.com/opcache/index.php`.
25+
The easiest way to start using the opcache-gui is to clone this repo, or copy/paste/download the `index.php` file to a location which your web server can load. Then point your browser to that location, such as `https://www.example.com/opcache/index.php`.
2626

2727
#### Install via composer
2828

2929
You can include the files with [Composer](https://getcomposer.org/) by running the command `composer require amnuts/opcache-gui`.
3030

31-
Once in your `vendor` directory, there are numerous ways in which you can use the interface. For example, if you're using a framework such as Symfony or Laravel, you could load opcache-gui into a `Controller`. Your requirements of setting it up within your framework of choice will vary, so it's not really possible to detail how to do that within this readme... but I have faith in your ability to figure it out!
31+
Once in your `vendor` directory, there are number of ways in which you can use the interface. For example, if you're using a framework such as Symfony or Laravel, you could load opcache-gui into a `Controller`. Your requirements of setting it up within your framework of choice will vary, so it's not really possible to detail how to do that within this readme... but I have faith in your ability to figure it out!
3232

3333
The namespace used for the class is `Amnuts\Opcache`, so once the dependency is in your `autoload.php` you can use the `\Amnuts\Opcache\Service` class. For example, you could do something like:
3434

@@ -47,9 +47,9 @@ $options = [/* ... */];
4747
$opcache = (new Service($options))->handle();
4848
```
4949

50-
Then you can create whatever view you want with which to show the opcache details. Although there is a pretty neat React-based interface available for you in this repo.
50+
Then, you can create whatever view you want with which to show the opcache details. Although there is a pretty neat React-based interface available for you in this repo.
5151

52-
Alternatively, include `vendor/amnuts/opcache-gui/index.php` directly and this'll give you the same result as just copying/pasting the `index.php` somewhere.
52+
Alternatively, include `vendor/amnuts/opcache-gui/index.php` directly and this will give you the same result as just copying/pasting the `index.php` somewhere.
5353

5454
```php
5555
<?php
@@ -59,7 +59,7 @@ Alternatively, include `vendor/amnuts/opcache-gui/index.php` directly and this'l
5959
require_once __DIR__ . '/../vendor/amnuts/opcache-gui/index.php';
6060
```
6161

62-
You could even simply create a symlink to the `index.php` that's in the `vendor` directory:
62+
You could even create a symlink to the `index.php` that's in the `vendor` directory:
6363

6464
```shell script
6565
ln -s /var/www/vendor/amnuts/opcache-gui/index.php /var/www/html/opcache.php
@@ -97,7 +97,7 @@ $options = [
9797
];
9898
```
9999

100-
If you want to change any of the defaults, you can pass in just the ones you want to change if you're happy to keep the rest as-is. Just alter the array at the top of the `index.php` script (or pass in the array differently to the `Service` class).
100+
If you want to change any of the defaults, you can pass in just the ones you want to change if you're happy to keep the rest as-is. Alter the array at the top of the `index.php` script (or pass in the array differently to the `Service` class).
101101

102102
For example, the following would change only the `allow_reset` and `refresh_time` values but keep everything else as the default:
103103

@@ -141,15 +141,15 @@ All the files currently in the cache are listed here with their associated stati
141141

142142
You can filter the results to help find the particular scripts you're looking for and change the way cached files are sorted. From here you can invalidate the cache for individual files or invalidate the cache for all the files matching your search.
143143

144-
If you do not want to show the file list at all then you can use the `allow_filelist` configuration option; setting it to `false` will suppress the file list altogether.
144+
If you do not want to show the file list at all, then you can use the `allow_filelist` configuration option; setting it to `false` will suppress the file list altogether.
145145

146-
If you want to adjust the pagination length you can do so with the `per_page` configuration option.
146+
If you want to adjust the pagination length, you can do so with the `per_page` configuration option.
147147

148148
![Screenshot of the Cached files list showing filtered results and pagination](http://amnuts.com/images/opcache/screenshot/cached-v3.png)
149149

150150
#### Ignored files
151151

152-
If you have set up a list of files which you don't want cache by supplying an `opcache.blacklist_filename` value, then the list of files will be listed within this tab.
152+
If you have set up a list of files which you don't want cached by supplying an `opcache.blacklist_filename` value, then the list of files will be listed within this tab.
153153

154154
If you have not supplied that configuration option in the `php.ini` file then this tab will not be displayed. If you set the `allow_filelist` configuration option to `false` then this tab will not be displayed irrespective of your ini setting.
155155

@@ -175,9 +175,9 @@ Also, if you choose to invalidate any files or reset the cache it will do this w
175175

176176
### Building it yourself
177177

178-
The interface has been designed around the principle of having just one file that anyone needs in order to get up and running. To fulfil this, there's a template file, language files, jsx and css, which are all used in order to create the interface and they're brought together in the build process.
178+
The interface has been designed around the principle of having just one file that anyone needs to get up and running. To fulfil this, there's a template file, language files, jsx, and css, which are all used to create the interface and they're brought together in the build process.
179179

180-
This build process will allow you to change the language used, how the required 3rd-party javascript libraries are included, the look and feel, or even the core components, should you wish.
180+
This build process will allow you to change the language used, how the required third-party javascript libraries are included, the look and feel, or even the core components, should you wish.
181181

182182
#### The build command
183183

@@ -199,7 +199,7 @@ The build process will create a compiled css file at `build/interface.css` and t
199199

200200
The CSS for the interface is in the `build/_frontend/interface.scss` file. Make changes there if you want to change the colours or formatting.
201201

202-
If you make any changes to the scss file then you'll need to run the build script in order to see the changes.
202+
If you make any changes to the scss file then you'll need to run the build script to see the changes.
203203

204204
#### The layout
205205

@@ -211,28 +211,36 @@ Run the build script again should you make changes here.
211211

212212
The wrapper PHP template used in the build process, and that acts to pass various bits of data to the ReactJS side of things, is located at `build/template.phps`. If you wanted to update the version of ReactJS used, or how the wrapper html is structured (such as wanting to pass additional things to the ReactJS side of things), then this would be the file you'd want to update.
213213

214-
The interface requires a few 3rd-party js files to function correctly. You have the option of being able to change where these are fetched (between CloudFare, JSDelivr, and Unpkg), or you can have js js completely local and in-line (for example, you have CSP policies in place and the remote urls are not whitelisted).
214+
The interface requires a few third-party js files to function correctly. You have the option of being able to change where these are fetched (between CloudFare, JSDelivr, and Unpkg), or you can have js completely local and in-line (for example, you have CSP policies in place and the remote urls are not allowed).
215215

216-
In order to change the location of the 3rd-party resources, use the `-r` or `--remote-js` option followed by either `cloudflare`, `jsdelivr`, or `unpkg`. For example, if you wanted to use _jsdelivr_ then you'd run the build command like this: `php ./build/build.php -r jsdelivr`. This defaults to `cloudflare`.
216+
To change the location of the third-party resources, use the `-r` or `--remote-js` option followed by either `cloudflare`, `jsdelivr`, or `unpkg`. For example, if you wanted to use _jsdelivr_ then you'd run the build command like this: `php ./build/build.php -r jsdelivr`. This defaults to `cloudflare`.
217217

218218
If you wanted to have the js in-line, then you can use the `-j` or `--local-js` flag when building, such as `php ./build/build.php -j`. This will fetch the remote script files and embed the js into main `index.php` file. If you want to build it again with remote files, run the command again without the flag. Fetching the files will take your `-r` option into consideration if you provide it.
219219

220220
#### The language
221221

222222
There's an old saying that goes, "If you know more than one language you're multilingual, if you don't you're British." Not only is that a damning indictment of the British mentality towards other languages, but also goes to explain why the UI has only so far been in English - because I am, for all my sins, British.
223223

224-
However, it is now possible to build the interface with a different language. Currently, thanks to contributors, French and Spanish are also supported. If anyone else wants to contribute additional language packs, please submit a PR!
224+
However, it is now possible to build the interface with a different language. Currently, thanks to contributors, French, German, and Spanish are also supported. If anyone else wants to contribute additional language packs, please submit a PR!
225225

226226
If the language pack is in the `build/_languages/` directory then you can use that with the `-l` or `--lang` flag. For example, if there is a `fr.json` language pack then you can use `php ./build/build.php -l fr` in order to build with that language.
227227

228-
There have been a few composer scripts added to help with the building. They are, `composer build`, `composer build-french`, and `composer build-spanish`.
228+
There have been a few composer scripts added to help with the building. They are `composer build`, `composer build-french`, `composer build-german` and `composer build-spanish`.
229229

230-
If you want to create a language file then `build/_languages/example.json` contains all you need. It's a simple json structure with the key being the English version which matches what's in the UI, and the value is what you're converting it to - which in the example file is just blank. If a value is empty or the index doesn't exist for a translation, then it'll just use the English version. This gives you the ability to replace some or all of the interface strings as you see fit.
230+
If you want to create a language file then `build/_languages/example.json` contains all you need. It's a simple json structure with the key being the English version which matches what's in the UI, and the value is what you're converting it to - which in the example file is just blank. If a value is empty or the index doesn't exist for a translation, then it'll just use the English version. This allows you to replace some or all of the interface strings as you see fit.
231231

232232
To get started with a new language, copy the `example.json` to the language you want that doesn't already exist - for example, `pt-br.json` or `pirate.json`. Then fill in the translations into the values. Once done, rebuild with `php ./build/build.php -l pt-br` or `php ./build/build.php -l pirate`.
233233

234234
## Releases
235235

236+
**Version 3.6.0**\
237+
Added German translation and various fixes thanks to @matthiasstraka (PR#123)
238+
Added fix for missing JIT in older PHP versions thanks to @cpeel (PR#120)
239+
Updated React and Axios packages
240+
Changes node-sass to sass, and various updates to support that
241+
Fixed #118
242+
Fixed #122
243+
236244
**Version 3.5.5**\
237245
Added Spanish translations thanks to @cvc90 (PR#110)
238246

build/_frontend/interface.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,9 @@ class Tab extends React.Component {
277277
function OverviewCounts(props) {
278278
if (props.overview === false) {
279279
return (
280-
<p class="file-cache-only">
281-
{props.txt(`You have <i>opcache.file_cache_only</i> turned on. As a result, the memory information is not available. Statistics and file list may also not be returned by <i>opcache_get_statistics()</i>.`)}
280+
<p className="file-cache-only"
281+
dangerouslySetInnerHTML={{__html: props.txt(`You have <i>opcache.file_cache_only</i> turned on. As a result, the memory information is not available. Statistics and file list may also not be returned by <i>opcache_get_statistics()</i>.`)}}
282+
>
282283
</p>
283284
);
284285
}
@@ -664,7 +665,7 @@ ReactCustomizableProgressbar.defaultProps = {
664665
function MemoryUsagePanel(props) {
665666
return (
666667
<div className="widget-panel">
667-
<h3 className="widget-header">memory usage</h3>
668+
<h3 className="widget-header">{props.txt('memory usage')}</h3>
668669
<div className="widget-value widget-info">
669670
<p><b>{props.txt('total memory')}:</b> {props.total}</p>
670671
<p><b>{props.txt('used memory')}:</b> {props.used}</p>
@@ -684,7 +685,7 @@ function StatisticsPanel(props) {
684685
<div className="widget-panel">
685686
<h3 className="widget-header">{props.txt('opcache statistics')}</h3>
686687
<div className="widget-value widget-info">
687-
<p><b>{props.txt('number of cached')} files:</b> {props.num_cached_scripts}</p>
688+
<p><b>{props.txt('number of cached files')}:</b> {props.num_cached_scripts}</p>
688689
<p><b>{props.txt('number of hits')}:</b> {props.hits}</p>
689690
<p><b>{props.txt('number of misses')}:</b> {props.misses}</p>
690691
<p><b>{props.txt('blacklist misses')}:</b> {props.blacklist_miss}</p>
@@ -779,7 +780,7 @@ class CachedFiles extends React.Component {
779780
}
780781

781782
if (this.props.allFiles.length === 0) {
782-
return <p>{this.props.txt('No files have been cached or you have <i>opcache.file_cache_only</i> turned on')}</p>;
783+
return <p dangerouslySetInnerHTML={{__html: this.props.txt(`No files have been cached or you have <i>opcache.file_cache_only</i> turned on`)}}></p>;
783784
}
784785

785786
const { searchTerm, currentPage } = this.state;

build/_frontend/interface.scss

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,18 @@ $pagination-hover-font-color: #FFF;
2424

2525
$footer-border-color: #CCC;
2626

27-
@function toRGB ($color) {
28-
@return "rgb(" + red($color) + ", " + green($color) + ", " + blue($color)+ ")";
27+
@use "sass:meta";
28+
@use "sass:color";
29+
@use "sass:string";
30+
@use "sass:list";
31+
32+
@function toRGB($hex) {
33+
$color: if(meta.type-of($hex) == "string", string.unquote($hex), $hex);
34+
$list: color.channel($color, "red"), color.channel($color, "green"), color.channel($color, "blue");
35+
$r: list.nth($list, 1);
36+
$g: list.nth($list, 2);
37+
$b: list.nth($list, 3);
38+
@return "rgb(#{$r}, #{$g}, #{$b})";
2939
}
3040

3141
:root {
@@ -102,13 +112,15 @@ $footer-border-color: #CCC;
102112

103113
.nav-tab-link-reset {
104114
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="1.5em" height="1.5em" viewBox="0 0 24 24"><path d="M17.65 6.35A7.958 7.958 0 0 0 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0 1 12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z" fill="#{toRGB($nav-icon-color)}"/></svg>');
115+
105116
&.is-resetting {
106117
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="1.5em" height="1.5em" viewBox="0 0 24 24"><path d="M17.65 6.35A7.958 7.958 0 0 0 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0 1 12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z" fill="#{toRGB($nav-icon-active-color)}"/></svg>');
107118
}
108119
}
109120

110121
.nav-tab-link-realtime {
111122
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="1.5em" height="1.5em" viewBox="0 0 24 24"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8s8 3.58 8 8s-3.58 8-8 8z" fill="#{toRGB($nav-icon-color)}"/><path d="M12.5 7H11v6l5.25 3.15l.75-1.23l-4.5-2.67z" fill="#{toRGB($nav-icon-color)}"/></svg>');
123+
112124
&.live-update {
113125
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="1.5em" height="1.5em" viewBox="0 0 24 24"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8s8 3.58 8 8s-3.58 8-8 8z" fill="#{toRGB($nav-icon-active-color)}"/><path d="M12.5 7H11v6l5.25 3.15l.75-1.23l-4.5-2.67z" fill="#{toRGB($nav-icon-active-color)}"/></svg>');
114126
}
@@ -117,6 +129,7 @@ $footer-border-color: #CCC;
117129
.nav-tab-link-reset, .nav-tab-link-realtime {
118130
position: relative;
119131
padding-left: 50px;
132+
120133
&.pulse::before {
121134
content: "";
122135
position: absolute;
@@ -224,6 +237,7 @@ $footer-border-color: #CCC;
224237
&:nth-child(odd) {
225238
background-color: $table-row-color;
226239
}
240+
227241
&:nth-child(even) {
228242
background-color: $table-row-color-alternative;
229243
}
@@ -293,7 +307,7 @@ $footer-border-color: #CCC;
293307
}
294308

295309
.nav-tab-link-reset,
296-
.nav-tab-link-realtime {
310+
.nav-tab-link-realtime {
297311
background-position: 24px 50%;
298312
}
299313

@@ -418,7 +432,7 @@ $footer-border-color: #CCC;
418432
transform: scale(1);
419433
opacity: 1;
420434
}
421-
50%,100% {
435+
50%, 100% {
422436
transform: scale(2);
423437
opacity: 0;
424438
}

0 commit comments

Comments
 (0)