We say that I have built a really awesome Symfony console application called HelloWorld. I now want it to be available everywhere on my computer, so I can run "helloworld" and it will output "HELLO WORLD". How would one accomplish such a thing? I've thought about adding it to my aliases file but I feel like there's a better way than that.
Asked
Active
Viewed 1,228 times
2 Answers
1
First this has nothing to do with php, symphony2 or console. This is about OS.
You need to put that application on a folder that is in PATH
or add that folder to the PATH
environment variable. This is OS dependent.
For Ubuntu:
https://askubuntu.com/questions/60218/how-to-add-a-directory-to-my-path
For Windows:
"Register" an .exe so you can run it from any command line in Windows
-
@bolow Where did I mention that this has anything to do with Python? But thanks for the answer, I appreciate it. I'll try this out :) And, the reason I added Symfony was because it was built with Symfony's Console Component and they have a special way of executing files. – djangokillen Dec 23 '14 at 15:49
-
@user3520448 in the tags – bolov Dec 23 '14 at 15:49
-
@bolow Symfony is built of off PHP. This also has a lot to do with console, because I want it to be executable in the console. I'm sorry if i bothered you as you down voted my question, but I hope you have a good continued day! :) – djangokillen Dec 23 '14 at 15:54
-
I am sorry, this is not Facebook where we want "likes" and we are bitter about "dislikes". If I down-voted your question or not I did it in the spirit of what I consider a bad question for this site or on the contrary an ok question. You didn't bothered me as I answered your question to the best I could with the information you gave and my knowledge and my willing to spare time for it. If the first paragraph in my answer seems aggressive in any way that was not my intention. I just pointed out that your problem is not specific to a kind of application. – bolov Dec 23 '14 at 16:02
-
@bolow You must have misunderstood me. I'm not talking about likes or dislikes, and I'm not considering your answer aggressive or mean in any kind if way. That's why I wrote "But thanks for the answer, I appreciate it". But thanks for letting me know - I didn't know that was the reason you down voted my question. :) – djangokillen Dec 23 '14 at 16:18
-
this can go on quite a while so I stop. Just please let me know if you managed to get it working. – bolov Dec 23 '14 at 16:22
-
@bolow No, but figured out another way that worked :) Thanks for your help anyway! – djangokillen Dec 23 '14 at 16:27
-
then add that as an answer so that others can benefit from it too. – bolov Dec 23 '14 at 16:28
-
@bolow It's quite specific, because I coded a symfony console application and uploaded it to Packagist and GitHub. I did a composer global require on this package, so it does not answer the question. But I'm sure your answer still works, so I will select that. – djangokillen Dec 23 '14 at 16:29
0
If you're using Linux, just add an alias to it in your .bashrc file:
alias mycommand='/usr/bin/php /path/to/myapp/app/console my:command'

Jason Roman
- 8,146
- 10
- 35
- 40