amnuts / opcache-gui

A clean, effective and responsive interface for Zend OPcache
1.23k stars 198 forks source link

How to access (under which URL) ? #45

Closed panique closed 4 years ago

panique commented 4 years ago

Hi there,

thanks for putting work into this project, I highly adore this. However, I could not find any information in the README that shows how to access the GUI when installing via Composer, even when working through the docs multiple times and even reading most of the code.

Can you please add this extremely essential info ? :)

fyrye commented 4 years ago

Since you're using composer, there are way too many usage examples to document. For example if you're using a Framework like Symfony/Laravel, you could load opcache-gui in a Controller. So where access exists and how it is initialized, is ultimately up to you to decide and configure. You will also need to configure your own security options based on your environment to protect file access. Although general usage of OpcacheGui\OpCacheService::init(); should be documented somewhere in the README or USAGE file.


For the below examples change /var/www/html with your DOCUMENT_ROOT path and /var/www/vendor with your composer vendor path. e.g. to allow viewing at https://example.com/opcache.php

First, as with any composer package, create a file to load OpcacheGui\OpCacheService. Again this is up to you to configure for your environment.

touch /var/www/html/opcache.php

Then edit the file to load the composer autoload.php file and instantiate the OpcacheGui\OpCacheService object.

<?php
/** /var/www/html/opcache.php */
require_once __DIR__ . `/../vendor/autoload.php`;

/** specify your options */
$options = array(/* ... */);

\OpcacheGui\OpCacheService::init($options);

Alternatively include amnuts/opcache-gui/index.php directly to use the default $options

<?php
/** /var/www/html/opcache.php */
require_once __DIR__ . `/../vendor/amnuts/opcache-gui/index.php`;

Or as the README states, copy amnuts/opcache-gui/index.php into your document path and make changes to the file as desired..

cp /var/www/vendor/amnuts/opcache-gui/index.php /var/www/html/opcache.php
amnuts commented 4 years ago

That was a great response @fyrye, thank you!

I'll attempt to update the README soon. I'm a little behind with making updates to the opcahce-gui since the newer version of PHP have come out, so need to carve out time for it properly. 😄