/**
  * Starts the shell.
  */
 public function actionRun()
 {
     $vars = get_defined_vars();
     $vars['this'] = Yii::$app;
     $sh = new \Psy\Shell();
     $sh->setScopeVariables($vars);
     $sh->run();
     return self::EXIT_CODE_NORMAL;
 }
Exemple #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->boot($input, $output);
     $cv = new Application();
     $sh = new \Psy\Shell();
     $sh->addCommands($cv->createCommands());
     // When I try making a new matcher, it doesn't seem to get called.
     //$sh->addTabCompletionMatchers(array(
     //  new ApiMatcher(),
     //));
     $sh->run();
 }
 /**
  * Invoke a Psy Shell from the current context.
  *
  * For example:
  *
  *     foreach ($items as $item) {
  *         \Psy\Shell::debug(get_defined_vars());
  *     }
  *
  * If you would like your shell interaction to affect the state of the
  * current context, you can extract() the values returned from this call:
  *
  *     foreach ($items as $item) {
  *         extract(\Psy\Shell::debug(get_defined_vars()));
  *         var_dump($item); // will be whatever you set $item to in Psy Shell
  *     }
  *
  * Optionally, supply an object as the `$bind` parameter. This determines
  * the value `$this` will have in the shell, and sets up class scope so that
  * private and protected members are accessible:
  *
  *     class Foo {
  *         function bar() {
  *             \Psy\Shell::debug(get_defined_vars(), $this);
  *         }
  *     }
  *
  * This only really works in PHP 5.4+ and HHVM 3.5+, so upgrade already.
  *
  * @param array  $vars Scope variables from the calling context (default: array())
  * @param object $bind Bound object ($this) value for the shell
  *
  * @return array Scope variables from the debugger session.
  */
 public static function debug(array $vars = array(), $bind = null)
 {
     echo PHP_EOL;
     if ($bind !== null) {
         $vars['this'] = $bind;
     }
     $sh = new \Psy\Shell();
     $sh->setScopeVariables($vars);
     $sh->run();
     return $sh->getScopeVariables();
 }
Exemple #4
0
#!/usr/bin/env php
<?php 
$app = (require dirname(__DIR__) . '/app/start.php');
$app->boot();
/**
 * This creates a Psysh interactive PHP shell. The $app variable, which you can
 * use to get access to all of the application's services, is available.
 *
 * Note that you must install the psy/psysh composer package to use this feature
 * - it does not come installed with the framework.
 *
 * @link http://psysh.org/
 */
Psy\Shell::debug(['app' => $app]);
Exemple #5
0
 /**
  * Invoke a Psy Shell from the current context.
  *
  * For example:
  *
  *     foreach ($items as $item) {
  *         \Psy\Shell::debug(get_defined_vars());
  *     }
  *
  * If you would like your shell interaction to affect the state of the
  * current context, you can extract() the values returned from this call:
  *
  *     foreach ($items as $item) {
  *         extract(\Psy\Shell::debug(get_defined_vars()));
  *         var_dump($item); // will be whatever you set $item to in Psy Shell
  *     }
  *
  * @param array $vars Scope variables from the calling context (default: array())
  *
  * @return array Scope variables from the debugger session.
  */
 public static function debug(array $vars = array())
 {
     echo PHP_EOL;
     $sh = new \Psy\Shell();
     $sh->setScopeVariables($vars);
     $sh->run();
     return $sh->getScopeVariables();
 }