Since version 5.4.0. PHP comes with a built in web server. If you're doing anything significant, chances are that you'll likely use Vagrant or similar to manage your local environment(s).
However, if you're a Mac user. Your computer already comes with PHP installed. The same is true for some other operating systems and even if not included by default, you can always install it. Even on Windows.
Before we begin. As listed in the official PHP docs. This server is meant for application development, not production.
Since I'm a Mac user, this setup will be geared towards Mac. However, other than the directory paths. The same principles apply for all OS.
At the time of this writing, the current version of PHP included with a Mac is 7.1.16.
To start the PHP server you can simply run the following from iTerm, Terminal, etc..
$ php -S localhost:8000
However, starting the server that way will use the default document root, which on a Mac is /Users/your_user_name. In most cases you probably don't have your PHP there. Passing the -t flag will allow you to specific the directory to use for your files. Assuming in your home Directory, you created a Development directory, you can start the PHP server using that folder as follows:
php -S localhost:8000 -t ~/Development/
PHP 7.1.16 Development Server started at Sat Jun 23 15:53:06 2018
Listening on http://localhost:8000
Document root is /Users/michael/Development/
Press Ctrl-C to quit.
Now you can open your browser and go to http://localhost:8000 to see your code.
One additional step I like to do is create an alias in your ~/.bash_profile to start your PHP server. Use vi or your favorite editor to add the following line to your .bash_profile. If the file doesn't exist, create it. Once saved, the changes take effect after you quit and relaunch your terminal app.
alias start-php-server="php -S localhost:8000 -t ~/Development/"
From there, all you have to do is type start-php-server from the command line and it will work the same as if you fully typed out php -S localhost:8000 -t ~/Development/.