Question

I mean, what's the right / best approach to write shell scripts, as the ones in Magento1 /shell folder?

Was it helpful?

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:

  1. Create a Command class (the recommended location is <your component root dir>/Console/Command).

    See app/code/Magento/CommandExample/Console/Command for examples.

  2. 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
scroll top