niorad.com/blog

Aliasing a php-server in Bash/Zsh-Terminal

November 15, 2014

If you often use the local php-server in OSX and got tired of always typing php -S localhost:8000, here’s a little shortcut. Open your “.zshrc” or “.bashrc”-file and add the following line:

function p() { 
    php -S localhost:$1;
  }

Save and close. Open a new terminal-window. Now you can start a php-server by typing

p 8000

The number after the “p” is the port the server will listen to. Please note that this will only work with OSX-Mavericks or higher.