承接 steverobbins/magento-shell 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

steverobbins/magento-shell

最新稳定版本:v1.0

Composer 安装命令:

composer require steverobbins/magento-shell

包简介

Magento Improved Shell

关键字:

README 文档

README

Join the chat at https://gitter.im/steverobbins/Magento-Shell

Master Build Status Master Code Quality

OMG COLORS

Drool

Add some style to your Magento scripts.

Sample

Usage

Extend the shell/local/abstract.php class and put your logic in the run() method, like you normally would with a Magento shell script.

Output

Instead of echoing, use the $this->log object. You can output messages using one of Zend_Log's levels

<?php

class Zend_Log
{
    const EMERG   = 0;  // Emergency: system is unusable
    const ALERT   = 1;  // Alert: action must be taken immediately
    const CRIT    = 2;  // Critical: critical conditions
    const ERR     = 3;  // Error: error conditions
    const WARN    = 4;  // Warning: warning conditions
    const NOTICE  = 5;  // Notice: normal but significant condition
    const INFO    = 6;  // Informational: informational messages
    const DEBUG   = 7;  // Debug: debug messages
}

Example:

<?php

require_once 'abstract.php';

class Local_Shell_MyScript extends Local_Shell_Abstract
{
    public function run()
    {
        $this->log->debug('Hello World!');
    }
}

Progress Bar

Create a progress bar with $bar = $this->progressBar($count);, where $count is an integer of how many items you will iterate over. $bar->update($i); as you walk through, then $bar->finish(); when complete.

Example:

<?php

require_once 'abstract.php';

class Local_Shell_MyScript extends Local_Shell_Abstract
{
    public function run()
    {
        $collection = Mage::getModel('catalog/product')->getCollection();
        $count      = $collection->count();
        $bar        = $this->progressBar($count);
        $i          = 0;
        foreach ($collection as $product) {
            $product->setDescription(strip_tags($product->getDescription()))
                ->save();
            $bar->update(++$i);
        }
        $bar->finish();
    }
}

Logging

Output is automatically logged to var/log/shell_local_<scriptName>.log.

Alternatively, you can specify your own log file by setting the public $logFile variable in you script.

Support

Please create an issue for all bugs and feature requests

Contributing

Fork this repository and send a pull request to the dev branch

License

WTF Public License 2.0

统计信息

  • 总下载量: 29
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 49
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 49
  • Watchers: 6
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: WTFPL
  • 更新时间: 2015-05-08