forikal-uk/xmlauthor-example-command

该包已被废弃,不再维护。作者建议使用https://github.com/xmlsquad/xmlauthor-example-command包。

管理xml文件的示例命令。

v0.3.3 2018-10-14 20:43 UTC

This package is not auto-updated.

Last update: 2019-02-20 19:23:34 UTC


README

一个作为xmlauthor命令示例的git项目。

先决条件

安装

  • 安装依赖

    composer install
  • 尝试 hello-world 命令

    bin/hello-world --configFilename=XmlAuthoringProjectSettings.yaml.dist

构建自己的命令

  • 新命令应该

    • 在 Symfony 3.4 控制台应用程序中运行。请参阅 Symfony 创建命令的文档。拥有自己的git仓库项目
    • 在项目仓库中存储测试(一个或多个PHPUnit/Behat等)
    • 与 Symfony 3.4 兼容,并且
    • 充分利用 symfony/console 项目。例如:$ composer require symfony/console:~3.4
    • 遵守 允许命令自动注册的约定
    • 由最终用户以composer包的形式安装
    • 尽可能重用现有库。例如;
    • 尽可能使用 PSR-4 自动加载
    • 跨平台兼容;在Windows 10、MacOS High Sierra和Linux的命令行上运行。
    • 提供README.md说明如何在 . 中安装和使用命令。
  • 示例命令

    # src/Command/NewCommand.php
    namespace XmlSquad\PackageName\Command;
    
    use XmlSquad\Library\Command\AbstractCommand;
    
    class NewCommand extends AbstractCommand
    {
        public function __construct()
        {
            # Specify command's name
            parent::__construct('new-command');
        }
    
        /**
         * {@inheritdoc}
         */
        protected function execute(InputInterface $input, OutputInterface $output)
        {
            try {
                $configFilename = $input->getOption('configFilename');
                $configOptions = $this->getConfigOptions($configFilename);
    
                dump($configOptions);
            } catch (FileNotFoundException $e) {
                $output->writeln(
                    $e->getMessage()
                );
            }
        }
    }

测试

vendor/bin/phpunit

待办事项

[ ] 使用虚拟文件系统的测试