If you are getting this error 'Could not open input file: bin/magento' while trying to run certain magento commands in your terminal in localhost, then you can try this solution which worked for me.
I ran into this issue, because I'd accessed the root directory of my Magento installation from my terminal. Everything was working fine until now. I then deleted my Magento installation, created a new folder with the same name as the deleted folder. Now remaining in the same terminal window, without changing path or closing the terminal, I was trying to run the magento shell commands. This was the reason I was running into the above error.
To solve this issue, I simply closed my terminal, opened it again, checked into the root directory of my magento installation, and now the commands were running fine.
Also check, while at the Terminal, you are inside the Root Directory of your Magento Installation, else you will get this ERROR again.
I ran into this issue, because I'd accessed the root directory of my Magento installation from my terminal. Everything was working fine until now. I then deleted my Magento installation, created a new folder with the same name as the deleted folder. Now remaining in the same terminal window, without changing path or closing the terminal, I was trying to run the magento shell commands. This was the reason I was running into the above error.
To solve this issue, I simply closed my terminal, opened it again, checked into the root directory of my magento installation, and now the commands were running fine.
Also check, while at the Terminal, you are inside the Root Directory of your Magento Installation, else you will get this ERROR again.