barbushin / php-console

Handle PHP errors, dump variables, execute PHP code remotely in Google Chrome
https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef
MIT License
1.34k stars 283 forks source link

Problem with evalprovider #117

Closed alfiqmiq closed 8 years ago

alfiqmiq commented 8 years ago

PHP7, PhpConsole 07801c3

if I use code from examples:

$connector = PhpConsole\Helper::register();
if($connector->isActiveClient()) {
    $handler = PC::getHandler();
    $handler->start();

    $connector->setSourcesBasePath(__DIR__);
    $connector->setPassword('MyPass');

    $evalProvider = $connector->getEvalDispatcher()->getEvalProvider();
    $evalProvider->disableFileAccessByOpenBaseDir();
    $evalProvider->addSharedVar('uri', $_SERVER['REQUEST_URI']);
    $evalProvider->addSharedVarReference('post', $_POST);
    $connector->startEvalRequestsListener();
}

than put:

return 2+2;

after CTRL + enter i got on console reply:

Cannot declare class PhpConsole\Storage, because the name is already in use -

if I use my older code (that worked for me before):

$connector = PhpConsole\Helper::register();
    if($connector->isActiveClient()) {
        $connector->setSourcesBasePath(__DIR__);
        $connector->setPassword('MyPass');
        $connector->getDebugDispatcher()->detectTraceAndSource = true;

        $evalProvider = $connector->getEvalDispatcher()->getEvalProvider();
        $evalProvider->disableFileAccessByOpenBaseDir();
        $evalProvider->addSharedVar('_DEBUG', ['post' => $_POST, 'get' => $_GET, 'session' => $_SESSION, 'server' => $_SERVER]);
        $connector->startEvalRequestsListener();

        $handler = PhpConsole\Handler::getInstance();
        $handler->setHandleErrors(true);
        $handler->setHandleExceptions(true);
        $handler->start();
    }   

on console I got: Console was cleared and nothing else

on other machine with PHP 5.4 and older version of PhpConsole everyting seems to be ok.

alfiqmiq commented 8 years ago

And another info, PC::debug($variable); worjs fine from *.php files

alfiqmiq commented 8 years ago

Another test:

$connector = PhpConsole\Helper::register();
if($connector->isActiveClient()) {
    $connector->setSourcesBasePath(__DIR__);
    $connector->setPassword('DupaWeza.8');
    $connector->getDebugDispatcher()->detectTraceAndSource = true;

    $evalProvider = $connector->getEvalDispatcher()->getEvalProvider();
    $evalProvider->disableFileAccessByOpenBaseDir();
    $evalProvider->addSharedVar('_DEBUG', ['post' => $_POST, 'get' => $_GET, 'session' => $_SESSION, 'server' => $_SERVER]);

    $handler = PhpConsole\Handler::getInstance();
    $handler->setHandleErrors(true);
    $handler->setHandleExceptions(true);
    $handler->start();

    $connector->startEvalRequestsListener();
}

return 2+2; ctrl + enter

and response:

Cannot declare class PhpConsole\Storage, because the name is already in use -phar:///somePath/lib/phpConsole.phar/Storage.php:15

alfiqmiq commented 8 years ago

Update: Problem with PHP7 occurs only from .phar that was build using examples/utils/build_phar.php

the same phar build with PHP 5.6 works fine.

barbushin commented 8 years ago

PHAR builder is removed from php-console utils.