We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

Here is a simple hello world command run using the command

– Please create the following module for command :


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_Module" setup_version="0.1.0"/>
  • Create a new model class, it will contain the options, description, and logic of your command.


    namespace VendorModuleModel;
    use SymfonyComponentConsoleCommandCommand;
    use SymfonyComponentConsoleInputInputInterface;
    use SymfonyComponentConsoleOutputOutputInterface;
    class Generation extends Command
        protected function configure()
                 ->setDescription('The description of you command here!');
        protected function execute(InputInterface $input, OutputInterface $output)
            $output->writeln('Hello World!');


    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
        <type name="MagentoFrameworkConsoleCommandList">
                <argument name="commands" xsi:type="array">
                    <item name="create" xsi:type="object">VendorModuleModelGeneration</item>

    Now, run upgrade command to register module : bin/magento setup:upgrade

    To run the command, just create :

    bin/magento custom:create.

Then add your own logic under the execute() method.

Please let us know if this article is helpful to you.


    Recent Articles
    Get a Free Quote

      Let’s initiate a discussion!!