Magento2 - is there any class such as Mage_Shell_Abstract to extend?
-
10-10-2020 - |
Question
I mean, what's the right / best approach to write shell scripts, as the ones in Magento1 /shell folder?
Solution
Magento 2 uses the Symfony Console component. So you are not supposed to write single PHP scripts anymore, but commands that will be executed with bin/magento
Documentation: How to add CLI commands
Summary:
Following is a summary of the process:
Create a Command class (the recommended location is
<your component root dir>/Console/Command
).See
app/code/Magento/CommandExample/Console/Command
for examples.Declare your Command class in
Magento\Framework\Console\CommandListInterface
using dependency injection (<your component root dir>/etc/di.xml
).Clean the cache and compiled code directories:
cd <your Magento install dir>/var rm -rf cache/* page_cache/* di/* generation/*
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange