protected function execute(InputInterface $input, OutputInterface $output) { $application = $this->getApplication(); $application->setCatchExceptions(false); $application->setAutoExit(false); $container = $this->getContainer(); $shell = new Shell(); $shell->debug(['container' => $container, 'kernel' => $container->get('kernel'), 'parameters' => $container->getParameterBag()->all()]); }
/** * Handle uncaught exceptions * * @param \Exception $exception */ public function onException(\Exception $exception) { $this->outputDriver->send(PHP_EOL); $this->sendErrorLine(''); $this->sendErrorLine('Error: an exception has occurred'); $this->sendErrorLine(''); $this->sendErrorLine('Message: ' . $exception->getMessage()); $this->sendErrorLine(''); $this->sendErrorLine('File: ' . $exception->getFile()); $this->sendErrorLine('Line: ' . $exception->getLine()); $this->sendErrorLine(''); $this->sendErrorLine('For more details please check the logs'); $this->sendErrorLine(''); $this->outputDriver->send(PHP_EOL); if ($this->inputDriver->readChoice("Debug exception in console ?", ['y', 'n']) == 'y') { Shell::debug(['exception' => $exception]); } }
/** * Interactive PHP console. * * ## DESCRIPTION * * `wp shell` allows you to evaluate PHP statements and expressions interactively, from within a WordPress environment. This means that you have access to all the functions, classes and globals that you would have access to from inside a WordPress plugin, for example. * * ## OPTIONS * * [--basic] * : Start in fail-safe mode, even if Boris is available. */ public function __invoke($_, $assoc_args) { $implementations = array('\\Psy\\Shell', '\\Boris\\Boris', '\\WP_CLI\\REPL'); if (\WP_CLI\Utils\get_flag_value($assoc_args, 'basic')) { $class = '\\WP_CLI\\REPL'; } else { foreach ($implementations as $candidate) { if (class_exists($candidate)) { $class = $candidate; break; } } } if ('\\Psy\\Shell' == $class) { \Psy\Shell::debug(); } else { $repl = new $class("\nwp> "); $repl->start(); } }
/** * This method will be called if this command is triggered * * @param ArgumentsContainer $arguments * * @return mixed */ public function execute(ArgumentsContainer $arguments) { Shell::debug(); exit(0); }
<?php namespace YOUR_NAMESPACE_HERE; use Symfony\Component\Console\Application; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Psy; /** @var $app \Silex\Application */ $console = new Application("YOUR_APPLICATION_NAME_HERE", '0.0.1'); $console->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', 'dev')); $console->register('shell')->setDescription('PHP Shell with $app loaded for quick scripting')->setCode(function (InputInterface $input, OutputInterface $output) use($app) { Psy\Shell::debug(['app' => $app]); }); return $console;
/** * Command to return the eval-able code to startup PsySH in interactive debugger * Works the same way as eval(\Psy\sh()); * psy/psysh must be loaded in your project * @link http://psysh.org/ * @link https://github.com/cakephp/cakephp/blob/master/src/basics.php * @return string */ function breakpoint() { if (!WP_DEBUG) { return; } if ((PHP_SAPI === 'cli-server' || PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && class_exists('\\Psy\\Shell')) { if (Strata::isBundledServer()) { Strata::app()->getLogger("StrataConsole")->debug("\n\nLaunching debugger...\n\n"); } list(, $caller) = debug_backtrace(false); extract(\Psy\Shell::debug(get_defined_vars(), isset($caller) ? $caller : null)); return; } trigger_error("psy/psysh must be installed and you must be in a CLI environment to use the breakpoint function", E_USER_WARNING); }
$this->credentials = null; } protected function doRequest($request) { if ($this->credentials !== null) { $request->attributes->set('indieauth.client.token', $this->credentials); } return parent::doRequest($request); } } $console = new Application("Shrewdness", '0.0.1'); $console->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', 'dev')); $console->register('shell')->setDescription('PHP Shell with $app loaded for quick scripting')->setCode(function (InputInterface $input, OutputInterface $output) use($app) { $app['exception_handler']->disable(); $app['debug'] = True; Psy\Shell::debug(['app' => $app, 'client' => new LoginableClient($app)]); }); $console->register('resubscribe')->setDescription('Resubscribe to all subscriptions')->addOption('unsubscribe', 'u', InputArgument::OPTIONAL, 'Unsubscribe from each feed before re-subscribing', False)->setCode(function (InputInterface $input, OutputInterface $output) use($app) { /** @var Subscriptions\SubscriptionStorage $ss */ $ss = $app['subscriptions.storage']; /** @var Subscriptions\PushHub $dh */ $dh = $app['subscriptions.defaulthub']; $rq = new Routing\RequestContext(null, null, $app['host'], 'https'); $app['url_generator']->setContext($rq); foreach ($ss->getSubscriptions() as $subscription) { if ($input->getOption('unsubscribe')) { $output->writeln("Unsubscribing from {$subscription['topic']}"); if ($subscription['hub'] == $dh->getUrl()) { $unsubhub = $dh; } else { $unsubhub = new Subscriptions\PushHub($subscription['hub']);
protected function execute(InputInterface $input, OutputInterface $output) { $this->psysh->debug($this->psysh->getScopeVariables()); }