phpmemadmin icon indicating copy to clipboard operation
phpmemadmin copied to clipboard

Allow to use as vendor in custom project

Open kmajzlik opened this issue 7 years ago • 1 comments

I have Symfony project and i would like to implement this in Symfony route. Not really easy now.

This is where i am now and it works (except of assets which can be symlinked) relative good. But all header links are pointing to /index.php?.... Workaround can be to create own class which extends "App" and use own getDefaultTemplateVariables() fuction.

<?php

namespace App\Controller;

use Clickalicious\Memcached\Client;
use Clickalicious\PhpMemAdmin\App;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class MemcacheController extends AbstractController
{

    /**
     * @Route(
     *   "/memcache",
     *   name = "memcache"
     * );
     */
    public function memcachePage(Request $request)
    {
        define(
            'CLICKALICIOUS_PHPMEMADMIN_BASE_PATH',
            '/var/www/vendor/clickalicious/phpMemAdmin/'
        );

        $config_path = '../vendor/clickalicious/phpMemAdmin/app/.config.dist';
        $config = json_decode(file_get_contents($config_path));
        $config->cluster->hosts[0]->host = 'memcached';
        $config->render->auto = false;

        $client = new Client();
        $memcache = new App($config, $client);

        return new Response($memcache->render($_SERVER['SCRIPT_NAME'], $_GET));
    }

}

kmajzlik avatar Jan 08 '19 11:01 kmajzlik

So the key problem is in protected function getUrl. Why we need to use SERVER_NAME, SERVER_PORT etc? This is not good in Docker or some proxy for example. I think really better is this: $pageUrl = $_SERVER['REQUEST_URI']; (+ parse parameters + anchor).

kmajzlik avatar Jan 09 '19 10:01 kmajzlik