staempfli/magento-symfony-console

此包已被废弃且不再维护。没有建议的替代包。
此包的最新版本(1.0)没有可用的许可证信息。

安装: 139

依赖者: 0

建议者: 0

安全: 0

星标: 2

关注者: 3

分支: 0

开放问题: 0

类型:magento-module

1.0 2016-12-08 22:08 UTC

This package is auto-updated.

Last update: 2020-09-16 12:12:35 UTC


README

Project Status: Abandoned – Initial development has started, but there has not yet been a stable, usable release; the project has been abandoned and the author(s) do not intend on continuing development.

这是一个添加类似Magento 2中symfony console功能的Magento模块。

安装

composer require "staempfli/magento-symfony-console":"~1.0"

用法

<magento_dir>/bin/magento

添加命令

  1. 将你的模型类添加到etc/config.xml中可用的命令上

    <default>
        <staempfli_console>
            <commands>
                <unique_key>vendorname_packagename/console_sampleCommand</unique_key>
            </commands>
        </staempfli_console>
    </default>
    
  2. Model下创建你的类,并继承自Staempfli_Console_Model_Command

    <?php
    
    use Symfony\Component\Console\Input\InputInterface;
    use Symfony\Component\Console\Output\OutputInterface;
    
    class VendorName_PackageName_Model_Console_SampleCommand extends Staempfli_Console_Model_Command
    {
        protected function configure()
        {
            $this->setName('command:name')
                ->setDescription('Command Description')
                ->setHelp("Help Help!");
        }
    
        protected function execute(InputInterface $input, OutputInterface $output)
        {
           // ... Your actions here
        }
    }
    

自定义配置

如果你使用自定义的vendor-dir,你可以在你的项目etc/config.xml中配置它

<default>
    <staempfli_console>
        <vendor_dir>../vendor</vendor_dir> <!-- Related path from magento base dir -->
    </staempfli_console>
</default>

如果你需要symfony/console的特定版本,你可以在你的项目composer.json中设置它

composer require "symfony/console": "<version>"

先决条件

  • PHP >= 5.5.*
  • Magento >= 1.*