Domanda

Sto tentando di creare uno script di shell personalizzato che estrarrà un file zip nella mia directory media/tmp.

Ho creato un file Labirer.php nella directory della shell.Estende Mage_Shell_Abstract e RUN () Sembra questo:

/**
 * Run script
 *
 */
public function run()
{
    $_SESSION = array();
    if ($this->getArg('unzip')) {
        $zipFile = strval($this->getArg('unzip'));
        echo "Unzipping {$zipFile}";
    }elseif ($this->getArg('pendingList')) {
        echo "this\n";
    } else {
        echo $this->usageHelp();
    }
}
.

Il comando a cui sto eseguendo è php -f shell/labeler.php -- unzip file.zip.L'output che ottengo è: decomprimere 1

È stato utile?

Soluzione

Da quello che so, penso che la sintassi giusta sia la seguente:

php -f shell/labeler.php -- --unzip file.zip
.

La sintassi per lo script Shell in Magento è:

php -f script.php -- [options]
.

Dove le opzioni potrebbero essere solo una bandiera come questa:

php -f script.php -- test
.

In quel caso $this->getArg('test') restituirà 1 (true).

o potrebbe essere un valore come questo:

php -f script.php -- --test mytest
.

In quel caso $this->getArg('test') restituirà 'MyTest'

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top