PHP 5.4 New Features - Built-in Web Server
One of the new things that I like most in PHP is definitely the built-in webserver feature. But do not think of it as a replacement of the very popular Apache or Nginx web servers. It has been created for development purpose only and you should never use it in production.
You can start your PHP web server via the command line of your computer. There shouldn't be any problems as long as you have PHP version 5.4 above. Simply type:
php -S localhost:80
Note that you must specify which port to be used.
You can start a specific file or directory on your server by adding the path at the end, after the port number.
php -S localhost:80 /subdirectory/another_subdirectory/my_file.php
There is a big chance that you will get an error if you are on Windows:
'php' is not recognized as an internal or external command, operable program or batch file.
This is because you have tell Windows manually how to deal with "php". You can fix this by adding an environment variable to your system.
1. Open System Properties by typing in the start menu "View advanced system settings" or navigate to there by right-clicking the My Computer menu -> Properties -> Advanced System Settings -> Environment variables;
2. Find the system variable Path and click Edit.
3. Add your the path to your php directory at the end of the Variable value, separating with a semicolon.


