Published Date: 27 May 2022

I‑finity found themselves needing to create a local testing environment for a php site in Windows that had previously only been developed on in Linux. This posed a difficult problem as migrating the code and local deployment method to Windows was not something that we had done before.

It was also running on an outdated version symfony and there was very little documentation online about performing this kind of process.

PHP Setup

  1. 1 Download PHP

    To download PHP you can either go online and find a source or use Microsoft Platform Installer, for this article we have used PHP 5.6. Select download and the necessary files will be added to your computer/device.

  2. 2 Create a local URL

    Next you should create a local URL for your local project to be hosted and viewed upon. You do this by going to IIS manager and going into the sites folder, right clicking and selecting ‘Add Website’.

    Php setup
  3. 3 Configure URL details

    Set the site name to something you will recognise as your local version of PHP and the host name to php.local or something similarly informative. You should then set your physical path the a local folder that you create called ‘php’ this is just for testing purposes and can be deleted once this setup has been completed.

    Php Image
  4. 4 Set up path variables

    Now you should open the environment variables section and ensure that the path system variable contains the definition for your PHP installation, this will be located in: Program Files(x86)\iis express\PHP\5.6 – if it is not there then you should add it.

  5. 5 Create version file

    Now in the newly created local folder you named PHP referenced as the physical path in your new website creation in IIS manager, you need to create a new file. Create a text file and save as version.php to make it an executable file by php. Then inside of the newly saved document, add this text (indicated left).

    <?php phpinfo();>

  6. 6 Edit the hosts file

    Go to: C:\Windows\System32\drivers\etc and select the file title hosts. In this file you need to add a reference to the newly created domain you added in IIS manager. At the bottom of this file add a new line (indicated left) or to the name of your local site.

    127.0.0.1              php.local

Browse the test site

You should now be able to view your local site at http://php.local and if you navigate to /version.php it will display data about the version of PHP you have installed on your machine. This confirms that you have installed PHP successfully and setup the variables and requirements correctly.

Project Setup

Now you can go back to your IIS Manager and edit your newly created site. Changing the physical path to be the /web folder of the PHP project you wish to begin development on.

You can now go back to the same URL, http://php.local and navigate to the index or base view that you have set up in your project's /web folder (this was only for our specific project and your project may be structured in a different manner) and local development on your PHP project can begin.