Skip to content

Instantly share code, notes, and snippets.

@theodorocaliari
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theodorocaliari/f0184b92958cd921def2 to your computer and use it in GitHub Desktop.
Save theodorocaliari/f0184b92958cd921def2 to your computer and use it in GitHub Desktop.
<?php
/**
* Include the following code in your theme functions.php;
* but first you need to include PHP Console library using one of the methods
* described in PHP Console documentation.
*/
$phpConsole = PhpConsole\Handler::getInstance()->isStarted();
// This check makes sure PHP Console is instantiated only once.
if ( $phpConsole == false ) {
$handler = PhpConsole\Handler::getInstance();
$handler->start();
$connector = PhpConsole\Connector::getInstance();
// You can set your own password here
$connector->setPassword('your_password_here');
$connector->setSourcesBasePath(__DIR__);
$evalProvider = $connector->getEvalDispatcher()->getEvalProvider();
// You can share more variables too if you want, follow the two examples below:
$evalProvider->addSharedVar('uri', $_SERVER['REQUEST_URI']);
$evalProvider->addSharedVarReference('post', $_POST);
// The setting below deals with paths where your application is;
// the following values should include functions from WordPress core, every active plugin and the active theme.
$evalProvider->setOpenBaseDirs(array(__DIR__, WP_CONTENT_DIR));
$connector->startEvalRequestsListener();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment