ini-config -p all -a fancyparameter
The most common way to call a php script on the console is
/usr/bin/php /ugly/long/path/to/your/script.php -p all -a fancyparameter
Noone wants to rember this path all the time.
The community tells me to put an alias in the ./bashrc. But that wont work, if you want to use your php script as a cmdtool in a shellscript without putting the path to the script in an echo like that:
echo "php /path/to/your/long/ugly/network/php/script.php -a all -p parameter"
You have to do some more.
The shellscripts become ugly and unmaintainable.
To get your phpscripts running as an alias cmdtool you can just add an exportfunction to your ~/.bash_profile or ~/.bashrc and export this function instead of defining an alias, wich is deprecated, as I know.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#nano ~/bashrc | |
#add following code add the end of the file | |
fancyscript() { | |
php /path/to/your/php/script.php "$@" | |
} | |
export -f fancyscript |
now you can simlpy enter
fancyscript -p parametername
on your console.
The function in the ./bashrc is rebootsave, so, that you can use it after rebooting the whole wide world.
Keine Kommentare:
Kommentar veröffentlichen