1

I am trying to create my own script to be placed in my extension /bin folder so that once I finished it, it should work in this way

bin/mycommandname my-customcommand

instead of running the

   bin/magento 

Is there any documentation or something which someone can help me out in this regard ?

1
  • No thats not, i dont want to add just custom commands, please refer to the question above, instead i want to my create my own custom bin script like bin/my-bin-script-name instead of calling the bin/magento. Apr 3, 2018 at 8:54

1 Answer 1

0

First of all you should NOT add anything in folders other than app/code , app/design app/i18n. I think some scripts at magento root might also be acceptable but putting files in bin definitely isn't.

You can create a module for doing just what you asking for thanks to symphony's implementation in magento.

There is an article about making a simple console command here - http://devdocs.magento.com/guides/v2.2/extension-dev-guide/cli-cmds/cli-howto.html

Also here is sample module -

https://github.com/magento/magento2-samples/tree/master/sample-module-command

Hope it solved your issue.

3
  • thank for your response, agreed that we should never place anything outside of those folder but i read that inside your own extension folder magento allow us to create your own bin folder and custom commands so that those can be called with your custom command folder instead of calling the magento one. Apr 3, 2018 at 8:58
  • I guess what you are saying can be done,but you would have to do a lot of work including writing your own file which will bootstrap magento and initialize Magento\Framework\Console\Cli , but as long as you don't put file inside bin located in magento root you would never get the command format specified by you as it is the path to bin/magento. Apr 3, 2018 at 10:18
  • Also please mark the answer as accepted if it helped Apr 3, 2018 at 10:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.