DragonKind
Solid State Member
- Messages
- 9
- Location
- USA
Hey everyone, I am a complete beginner to PHP and was having trouble figuring out how to simply type one command to execute PHP script. If anyone knows PHP here, I'd really greatly appreciate any help with my puzzle.
Here are the two problems I am having:
I want to run my php program from the command line, but I always have to type "php programname" instead of just typing "programname" in the command line. How do I make it known to the shell that whenever I type "programname" it runs the program?
Also, I have some arguments that I parse using getopt(). I also have a configuration file, which has a $DEFAULT_ARGS setting. I want the user to be able to set the default args, and if they run program without arguments $DEFAULT_ARGS takes over and becomes the argument list.
Without writing my own parser, is there a way to "spoof" the argv[] variable or somehow make getopt() work with the string I've specified in the configuration file instead?
For example, if I wanted to run this on the command line: php program -a 300 --debug, instead I will have $DEFAULT_ARGS="-a 300 --debug" in my configuration file and simply write program to run the program. This is my end goal. If anyone can help that would be awesome.
Here are the two problems I am having:
I want to run my php program from the command line, but I always have to type "php programname" instead of just typing "programname" in the command line. How do I make it known to the shell that whenever I type "programname" it runs the program?
Also, I have some arguments that I parse using getopt(). I also have a configuration file, which has a $DEFAULT_ARGS setting. I want the user to be able to set the default args, and if they run program without arguments $DEFAULT_ARGS takes over and becomes the argument list.
Without writing my own parser, is there a way to "spoof" the argv[] variable or somehow make getopt() work with the string I've specified in the configuration file instead?
For example, if I wanted to run this on the command line: php program -a 300 --debug, instead I will have $DEFAULT_ARGS="-a 300 --debug" in my configuration file and simply write program to run the program. This is my end goal. If anyone can help that would be awesome.