Setting PHP for Windows

Setting PHP for Windows

This tutorial describes how to set up a development environment on a Windows computer for building PHP web applications with Adobe Dreamweaver.


This setup tutorial shows you how to complete the following tasks:
1.Install and run a PHP-enabled web server on your local computer
2.Define a PHP site in Dreamweaver CS5.

1. Download
PHP pages need to be processed through a web server. So, to develop with PHP in Dreamweaver, you need access to a PHP-enabled web server.The one chosen for this tutorial is XAMPP.You can download it from

2. Installing XAMPP
Installing and configuring XAMPP is usually quick and trouble-free, but things do sometimes go wrong.

After downloading XAMPP for Windows(Basic package self-extracting RAR archive),close all applications on your computer, and double-click the EXE file you downloaded.

A dialog box asks you where you want to install XAMPP. The default is C:\. If you select the default, the installer extracts all the necessary files to a new folder called C:\xampp. When expanded, the files occupy approximately 275MB.

When all the files have been extracted, the installer opens a Windows Command Prompt window, where you are asked to respond to a series of simple questions about installation options. Type y or n, depending on your preference, and press Enter.
The final stage of the XAMPP installation process involves setting options in a Command Prompt window.

3. Starting the servers
To start the Apache and MySQL servers, launch the XAMPP Control Panel from the Windows Start menu (if it's not already open), and click the Start button alongside Apache and MySQL. Confirmation that they have started successfully is displayed alongside, and the label on the Start buttons changes to Stop.

The XAMPP Control Panel confirms that Apache and MySQL are running.

4. Securing the database
To secure the database,launch a browser and type http://localhost/ into the address bar.
The XAMPP welcome screen appears after you select a language to use.

Click Security in the menu on the left of the screen. This opens a new browser window or tab with a report on the current security status of your installation. Scroll down below the status report, and click the following link: http://localhost/security/xamppsecurity.php. This displays the security console, which prompts you to create a password for the MySQL superuser, root.
Set the MySQL root password.

5. Testing the PHP installation
After installing XAMPP and securing the database, it's a good idea to test the PHP installation:
* Close the XAMPP security window or tab, and return to the welcome screen.
* Click phpinfo() in the menu on the left of the screen.
* If PHP has been installed successfully you'll see a page showing detailed information on your PHP setup.

6. Defining a PHP site in Dreamweaver CS5
Because PHP files need to be processed by a web server, you need to tell Dreamweaver where the testing server is located. You also need to tell Dreamweaver the correct URL to use when testing your files.

   Identifying the server document root
*      The document root is the top-level folder where the server looks for web pages. Its location
       depends on where and how you installed your PHP testing environment.
*      The default location for PHP setup is: * C:\xampp\htdocs
*      The URL for the document root is http://localhost/.

Specifying a working folder

To specify a working folder:
  1. In Dreamweaver, select Site > New Site.
  2. In the Site Name text box, type the name of your site, for example, PHP Test Site. This name identifies the project in Dreamweaver.
  3. Click the folder icon next to the Local Site Folder text box and browse to your testing server's document root.
  4. Create a subfolder of the document root called php_test, and select it.
  5. Click Open and then Select .
  6. Verify the settings in the Site Setup dialog box (see Figure 12) and click Save. (The location of the Local Site Folder will depend on your how you installed PHP.)

Verify the basic settings for the PHP test site.

Note: The folder name should not include any spaces or special characters. You should never use spaces or special characters in folder or file names for a website, because they cause problems on most PHP servers.
That's all you need to do to define a site in Dreamweaver. You don't need to define the remote or testing servers until you want to use them. However, since you're going to test the site right away, leave the Site Setup dialog box open.

Specifying a testing server for Dreamweaver

To specify a testing server:
  1. Select Servers in the column on the left of the Site Setup dialog box.
  2. Click the plus (+) button at the bottom left of the dialog box to add a new server.
  3. In the dialog box that opens, make sure that the Basic button is selected, and select Local/Network from the Connect Using list.
  4. Give the server a name, such as Local Testing.
  5. Set the Server Folder to the folder you specified as the Local Site Folder; in this example, php_test inside your server's document root.
  6. For the Web URL, type the URL you would use to get to the php_test folder inside the server's document root. Since the document root is the equivalent of http://localhost/, you need to type http://localhost/php_test/ in the Web URL text field (see Figure 13).

The basic settings for the testing server include the Server Folder and the Web URL.

  1. Select the Advanced button at the top of the dialog box. This reveals the options for both a remote server and a testing server.
  2. For the Server Model (in the Testing Server section) select PHP MySQL (see Figure 14).

Set the Server Model for the testing server to PHP MySQL.

  1. Click Save.
  2. This is a testing server, so make sure the Testing check box is selected in the Site Setup dialog box. If necessary, deselect the Remote check box (see Figure 15).

Make sure the Testing checkbox is selected.

  1. Click Save to save the changes you have made.

Testing the PHP site

Now that you have defined the site in Dreamweaver, you can test that everything works.
  1. Select File > New, and create a blank page, selecting PHP as the page type.
  2. Open Code view, and type the following code between the <body> tags:

<p>The time is now <?php echo date('H:i:s'); ?>.</p>

The code between the <?php ?> tags displays the current time.
  1. Switch to Design view, and save the page as timetest.php. The text inside the HTML <p> tags is displayed as normal, but the PHP code is replaced by a gold shield (see Figure 16).

The dynamic code is represented in Design view by a gold shield.

  1. Click the Live View button. The gold shield should be replaced by the current time (see Figure 17).

The PHP code is processed by the web server and displayed in Live view.

Congratulations! Your PHP development environment and site are now set up and you are ready to start developing PHP web applications in Dreamweaver.