99designs/repl-bundle

此包已被弃用且不再维护。作者建议使用 theofidry/psysh-bundle 包代替。
关于此包最新版本(2.0.2)没有可用的许可证信息。

将Boris repl命令添加到Symfony控制台

2.0.2 2021-06-29 04:18 UTC

This package is not auto-updated.

Last update: 2021-06-29 04:28:14 UTC


README

重要:此包不再处于活跃开发状态。请考虑使用 PsyshBundle 作为替代。

为Symfony控制台提供由 Boris 驱动的 repl 命令。

安装

将其添加为开发依赖到 composer.json

composer require --dev 99designs/repl-bundle

app/AppKernel.php 中注册此包

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // all your run-time bundles
        );

        if ($this->getEnvironment() == 'dev') {
            $bundles[] = new NinetyNine\Bundle\ReplBundle();
        }

        return $bundles;
    }
}

使用

通过Symfony控制台运行

app/console repl

以下变量被导入到全局命名空间

  • $kernel:应用程序内核
  • $container:DI容器

问题

Boris依赖于PHP的进程控制扩展 PCNTL。即使已经安装,你也可能看到如下错误

PHP Warning:  pcntl_fork() has been disabled for security reasons in /my-project/vendor/d11wtq/boris/lib/Boris/Boris.php on line 148
PHP Notice:  fwrite(): send of 1 bytes failed with errno=32 Broken pipe in /my-project/vendor/d11wtq/boris/lib/Boris/EvalWorker.php on line 205

如果看到这些错误,你需要编辑你的PHP CLI配置(通常位于 /etc/php5/cli/php.ini),以允许调用命名函数。