lexpress/console-service-provider

该软件包已被弃用且不再维护。没有建议替代软件包。

Silex 应用程序的控制台服务提供商

v1.0.0 2013-09-22 22:20 UTC

This package is not auto-updated.

Last update: 2020-01-24 15:18:01 UTC


README

ConsoleServiceProvider 允许在 Symfony Console 中启用 Silex,从而便于从任何其他服务提供商注册命令。

参数

  • console.name (可选): 您应用程序的名称。
  • console.version (可选): 您应用程序的版本。

服务

  • console: 控制台应用程序。使用 $app['console']->run()

注册

安装

在您的 Silex 应用程序中注册服务提供商。

$app->register(new LExpress\Silex\ConsoleServiceProvider(), array(
    'console.name'    => 'Wahou',
    'console.version' => '1.0',
));

注册命令

command.* 命名的服务将自动注册到控制台。

$app['command.propel.model.build'] = $app->share(function ($app) {
    return new Propel\Generator\Command\ModelBuildCommand();
});

运行控制台应用程序

控制台应用程序可以通过服务别名 console 在您的 Silex 应用程序中使用。要运行它,您可以在项目中创建一个可执行文件。

#!/usr/bin/env php
<?php

// Load the class loader
require __DIR__.'/vendor/autoload.php';

// Initialize your application with the ConsoleServiceProvider
$app = require __DIR__.'/app.php';

// Run the console with the default input/output
$app['console']->run();

许可证

ConsoleServiceProvider 采用 MIT 许可证。