Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use as vendor in custom project #30

Open
kmajzlik opened this issue Jan 8, 2019 · 1 comment
Open

Allow to use as vendor in custom project #30

kmajzlik opened this issue Jan 8, 2019 · 1 comment

Comments

@kmajzlik
Copy link

kmajzlik commented Jan 8, 2019

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
Copy link
Author

kmajzlik commented Jan 9, 2019

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant