Getting Started
Use the Current Stable Version (5.5)
If you are just getting started with PHP make sure to start with the current stable release of PHP 5.5. PHP has made great strides adding powerful new features over the last few years. Don’t let the minor version number difference between 5.2 and 5.5 fool you, it represents major improvements. If you are looking for a function or its usage, the documentation on the php.net website will have the answer.Built-in web server
You can start learning PHP without the hassle of installing and configuring a full-fledged web server (PHP 5.4+ required). To start the server, run the following from your terminal in your project’s web root:> php -S localhost:8000
Mac Setup
OSX comes prepackaged with PHP but it is normally a little behind the latest stable. Lion comes with PHP 5.3.6, Mountain Lion has 5.3.10, and Mavericks has 5.4.17.To update PHP on OSX you can get it installed through a number of Mac package managers, with php-osx by Liip being recommended.
The other option is to compile it yourself, in that case be sure to have installed either Xcode or Apple’s substitute “Command Line Tools for Xcode” downloadable from Apple’s Mac Developer Center.
For a complete “all-in-one” package including PHP, Apache web server and MySQL database, all this with a nice control GUI, try MAMP or XAMPP.
Windows Setup
PHP is available in several ways for Windows. You can download the binaries and until recently you could use a ‘.msi’ installer. The installer is no longer supported and stops at PHP 5.3.0.For learning and local development you can use the built in webserver with PHP 5.4+ so you don’t need to worry about configuring it. If you would like an “all-in-one” which includes a full-blown webserver and MySQL too then tools such as the Web Platform Installer, Zend Server CE, XAMPP and WAMP will help get a Windows development environment up and running fast. That said, these tools will be a little different from production so be careful of environment differences if you are working on Windows and deploying to Linux.
If you need to run your production system on Windows then IIS7 will give you the most stable and best performance. You can use phpmanager (a GUI plugin for IIS7) to make configuring and managing PHP simple. IIS7 comes with FastCGI built in and ready to go, you just need to configure PHP as a handler. For support and additional resources there is a dedicated area on iis.net for PHP.
Vagrant
Running your application on different environments in development and production can lead to strange bugs popping up when you go live. It’s also tricky to keep different development environments up to date with the same version for all libraries used when working with a team of developers.If you are developing on Windows and deploying to Linux (or anything non-Windows) or are developing in a team, you should consider using a virtual machine. This sounds tricky, but using Vagrant you can set up a simple virtual machine with only a few steps. These base boxes can then be set up manually, or you can use “provisioning” software such as Puppet or Chef to do this for you. Provisioning the base box is a great way to ensure that multiple boxes are set up in an identical fashion and removes the need for you to maintain complicated “set up” command lists. You can also “destroy” your base box and recreate it without many manual steps, making it easy to create a “fresh” installation.
Vagrant creates shared folders used to share your code between your host and your virtual machine, meaning you can create and edit your files on your host machine and then run the code inside your virtual machine.
A little help
If you need a little help to start using Vagrant there are two services that might be useful:- Rove: service that allows you to pregenerate typical Vagrant builds, PHP among the options. The provisioning is made with Chef.
- Puphpet: simple GUI to set up virtual machines for PHP development. Heavily focused in PHP. Besides local VMs, can be used to deploy to cloud services as well. The provisioning is made with Puppet。
https://github.com/codeguy/php-the-right-way
http://wulijun.github.io/php-the-right-way (中文版)