當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Psy\Shell類代碼示例

本文整理匯總了PHP中Psy\Shell的典型用法代碼示例。如果您正苦於以下問題:PHP Shell類的具體用法?PHP Shell怎麽用?PHP Shell使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Shell類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $config = $this->getPsyConfig();
     $psy_config = new Configuration($config);
     $psy_shell = new Shell($psy_config);
     $psy_shell->run();
 }
開發者ID:anna-framework,項目名稱:anna,代碼行數:7,代碼來源:DeskCommand.php

示例2: main

 public function main(array $argv)
 {
     $parser = $this->getParser();
     $parser->process($argv);
     if ($parser->optionIsSet("help")) {
         $this->out($parser->helpText());
         return 0;
     }
     if (!class_exists('Psy\\Shell')) {
         $this->err('<error>Unable to load Psy\\Shell.</error>');
         $this->err('');
         $this->err('Make sure you have installed psysh as a dependency,');
         $this->err('and that Psy\\Shell is registered in your autoloader.');
         $this->err('');
         $this->err('If you are using composer run');
         $this->err('');
         $this->err('<info>$ php composer.phar require --dev psy/psysh</info>');
         $this->err('');
         return 1;
     }
     $this->out("You can exit with <info>`CTRL-C`</info> or <info>`exit`</info>");
     $this->out('');
     $psy = new Shell();
     $psy->run();
     return 0;
 }
開發者ID:coretyson,項目名稱:coretyson,代碼行數:26,代碼來源:InterpreterShell.php

示例3: handle

 /**
  * Handle the command.
  *
  * @return void
  */
 public function handle()
 {
     $this->getApplication()->setCatchExceptions(false);
     $shell = new Shell();
     $shell->setIncludes($this->argument('include'));
     $shell->run();
 }
開發者ID:oxyzero,項目名稱:tempest,代碼行數:12,代碼來源:TinkerCommand.php

示例4: start

 /**
  * Start
  *
  * @return void
  */
 protected function start()
 {
     $configFile = $this->getOption("psy-config");
     $configuration = is_null($configFile) ? null : new Configuration(compact("configFile"));
     $shell = new Shell($configuration);
     $shell->run();
 }
開發者ID:Hiroto-K,項目名稱:Tw-Cron,代碼行數:12,代碼來源:ConsoleCommand.php

示例5: execute

    /**
     * @param InputInterface  $input
     * @param OutputInterface $output
     *
     * @return int|void
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $initialized = false;
        try {
            $this->detectMagento($output);
            $initialized = $this->initMagento();
        } catch (Exception $e) {
            // do nothing
        }
        $parser = new Parser(new Lexer());
        $cleaner = new CodeCleaner($parser);
        $consoleOutput = new ShellOutput();
        $config = new Configuration();
        $config->setCodeCleaner($cleaner);
        $shell = new Shell($config);
        $shell->setScopeVariables(['di' => $this->getObjectManager()]);
        if ($initialized) {
            $ok = Charset::convertInteger(Charset::UNICODE_CHECKMARK_CHAR);
            $edition = $this->productMeta->getEdition();
            $magentoVersion = $this->productMeta->getVersion();
            $consoleOutput->writeln('<fg=black;bg=green>Magento ' . $magentoVersion . ' ' . $edition . ' initialized.</fg=black;bg=green> ' . $ok);
        } else {
            $consoleOutput->writeln('<fg=black;bg=yellow>Magento is not initialized.</fg=black;bg=yellow>');
        }
        $help = <<<'help'
At the prompt, type <comment>help</comment> for some help.

To exit the shell, type <comment>^D</comment>.
help;
        $consoleOutput->writeln($help);
        $shell->run($input, $consoleOutput);
    }
開發者ID:ktomk,項目名稱:n98-magerun2,代碼行數:38,代碼來源:ConsoleCommand.php

示例6: main

 /**
  * Start the shell and interactive console.
  *
  * @return int|void
  */
 public function main()
 {
     if (!class_exists('Psy\\Shell')) {
         $this->err('<error>Unable to load Psy\\Shell.</error>');
         $this->err('');
         $this->err('Make sure you have installed psysh as a dependency,');
         $this->err('and that Psy\\Shell is registered in your autoloader.');
         $this->err('');
         $this->err('If you are using composer run');
         $this->err('');
         $this->err('<info>$ php composer.phar require --dev psy/psysh</info>');
         $this->err('');
         return 1;
     }
     $this->out("You can exit with <info>`CTRL-C`</info> or <info>`exit`</info>");
     $this->out('');
     Log::drop('debug');
     Log::drop('error');
     $this->_io->setLoggers(false);
     restore_error_handler();
     restore_exception_handler();
     $psy = new PsyShell();
     $psy->run();
     return 0;
 }
開發者ID:bostontrader,項目名稱:acctwerx,代碼行數:30,代碼來源:ConsoleShell.php

示例7: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->blink->bootstrap();
     $config = new Configuration();
     $config->getPresenter()->addCasters($this->casters);
     $shell = new Shell($config);
     return $shell->run();
 }
開發者ID:bixuehujin,項目名稱:blink,代碼行數:8,代碼來源:ShellCommand.php

示例8: actionIndex

 /**
  * Runs interactive shell
  */
 public function actionIndex()
 {
     $config = new Configuration();
     $config->getPresenter()->addCasters($this->getCasters());
     $shell = new Shell($config);
     $shell->setIncludes($this->include);
     $shell->run();
 }
開發者ID:yiisoft,項目名稱:yii2-shell,代碼行數:11,代碼來源:ShellController.php

示例9: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->startup($input, $output);
     $output->writeln('Press <info>CTRL + C</info> or type <info>exit</info> to quit');
     $this->nl();
     $psy = new PsyShell();
     $psy->run();
 }
開發者ID:francoisfaubert,項目名稱:strata,代碼行數:11,代碼來源:ConsoleCommand.php

示例10: execute

 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()]);
 }
開發者ID:navitronic,項目名稱:psymf,代碼行數:9,代碼來源:ReplCommand.php

示例11: fire

 /**
  * @return void
  */
 public function fire()
 {
     $this->getApplication()->setCatchExceptions(false);
     $config = new Configuration();
     $config->getPresenter()->addCasters($this->getCasters());
     $shell = new Shell($config);
     $shell->addCommands($this->getCommands());
     $shell->setIncludes($this->argument('include'));
     $shell->run();
 }
開發者ID:notadd,項目名稱:framework,代碼行數:13,代碼來源:TinkerCommand.php

示例12: getShell

 /**
  * Get instance of the Shell.
  * @return \Psy\Shell
  */
 public function getShell()
 {
     if (!$this->shell) {
         $config = new Configuration();
         $config->getPresenter()->addCasters($this->getCasters());
         $this->shell = new Shell($config);
         $this->shell->addCommands($this->getCommands());
     }
     return $this->shell;
 }
開發者ID:tralves,項目名稱:lumen-tinker,代碼行數:14,代碼來源:TinkerShell.php

示例13: __construct

 /**
  * ShellMessagesHandler constructor.
  * @param JupyterBroker $broker
  * @param SocketWrapper $iopubSocket
  * @param SocketWrapper $shellSocket
  * @param Logger $logger
  */
 public function __construct(JupyterBroker $broker, SocketWrapper $iopubSocket, SocketWrapper $shellSocket, Logger $logger)
 {
     $this->shellSoul = new Shell();
     $this->executeAction = new ExecuteAction($broker, $iopubSocket, $shellSocket, $this->shellSoul);
     $this->historyAction = new HistoryAction($broker, $shellSocket);
     $this->kernelInfoAction = new KernelInfoAction($broker, $shellSocket, $iopubSocket);
     $this->shutdownAction = new ShutdownAction($broker, $shellSocket);
     $this->logger = $logger;
     $broker->send($iopubSocket, 'status', ['execution_state' => 'starting'], []);
     $this->shellSoul->setOutput(new KernelOutput($this->executeAction, $this->logger->withName('KernelOutput')));
 }
開發者ID:Litipk,項目名稱:Jupyter-PHP,代碼行數:18,代碼來源:ShellMessagesHandler.php

示例14: run

 /**
  * Run the execution loop.
  *
  * Forks into a master and a loop process. The loop process will handle the
  * evaluation of all instructions, then return its state via a socket upon
  * completion.
  *
  * @param Shell $shell
  */
 public function run(Shell $shell)
 {
     list($up, $down) = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
     if (!$up) {
         throw new \RuntimeException('Unable to create socket pair.');
     }
     $pid = pcntl_fork();
     if ($pid < 0) {
         throw new \RuntimeException('Unable to start execution loop.');
     } elseif ($pid > 0) {
         // This is the main thread. We'll just wait for a while.
         // We won't be needing this one.
         fclose($up);
         // Wait for a return value from the loop process.
         $read = array($down);
         $write = null;
         $except = null;
         if (stream_select($read, $write, $except, null) === false) {
             throw new \RuntimeException('Error waiting for execution loop.');
         }
         $content = stream_get_contents($down);
         fclose($down);
         if ($content) {
             $shell->setScopeVariables(@unserialize($content));
         }
         return;
     }
     // This is the child process. It's going to do all the work.
     if (function_exists('setproctitle')) {
         setproctitle('psysh (loop)');
     }
     // We won't be needing this one.
     fclose($down);
     // Let's do some processing.
     parent::run($shell);
     // Send the scope variables back up to the main thread
     fwrite($up, $this->serializeReturn($shell->getScopeVariables()));
     fclose($up);
     exit;
 }
開發者ID:EnmanuelCode,項目名稱:backend-laravel,代碼行數:49,代碼來源:ForkingLoop.php

示例15: onException

 /**
  * 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]);
     }
 }
開發者ID:thinframe,項目名稱:karma,代碼行數:23,代碼來源:ErrorListener.php


注:本文中的Psy\Shell類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。