1

This question already has an answer here:

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 ?

marked as duplicate by Manoj Deswal, Jai, liyakat, Priyank, Prince Patel Apr 3 '18 at 10:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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. – Zeeshan Khuwaja Apr 3 '18 at 8:54
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.

  • 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. – Zeeshan Khuwaja Apr 3 '18 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. – Vivek Kumar Apr 3 '18 at 10:18
  • Also please mark the answer as accepted if it helped – Vivek Kumar Apr 3 '18 at 10:20

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