You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
dotfiles/.aliases.d/php-lang.sh

50 lines
1.5 KiB

php-web() {
if [ -z "$1" ]; then
php -S 127.0.0.1:9980 -t /var/www
else
php -S 127.0.0.1:9980 -t "$1"
fi
}
export MYLANIP=`ip -4 --color=never addr show enp2s0 | grep inet | awk '{print $2}' | cut -d/ -f1`
p() {
if [ -z "$1" ]; then
php -S "$MYLANIP":9980 &
else
php -S "$MYLANIP":9980 -t "$1" &
fi
job_output=$(jobs -l | tail -n 1)
job_number=$(echo "$job_output" | awk '{print $1}' | tr -d '[]+\-')
job_pid=$!
local RED='\033[0;31m'
local NC='\033[0m'
echo -e "\n To ${RED}Stop php: kill %$job_number ${NC}\n To make active: fg %$job_number \n"
echo -e "PID # $job_pid \n \t To end this program: kill -9 $job_pid"
echo -e "Remember Ctrl+C = Terminate an active Program and Ctrl+Z = Stop/Suspend an running Program \n"
}
php-lang() {
if [ "$(which php | wc -l)" -eq 1 ]; then
if [ -z "$1" ]; then
echo "version - Displays the version #."
echo "modules - Lists installed modules."
echo "run - Runs a Script."
echo "shell - Does an interactive shell."
echo "info - Dumps like PHP_info."
echo "web - Run with built-in web server on 127.0.0.1:9980 [web ROOT]"
else
case "$1" in
version) php -v;;
modules) php -m;;
run) php -f "$2";;
shell) php -a;;
info) php -i | less;;
web) php-web "$2";;
*) php-lang;;
esac
fi
else
echo "PHP, not install yet!"
echo "Do use your package manager to install PHP."
fi
}