Vous êtes sur la page 1sur 18

9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection

www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 1/18
Adobe Developer Connection / Dreamweaver Developer Center /
Setting up a PHP development
environment for Dreamweaver
Share on Facebook
Share on Twitter
Share on LinkedIn
Print
database Dreamweaver CS5
dynamic website file management
MySQL PHP site setup
by David Powers
http://foundationphp.com/
Content
Setting up PHP for Windows
Installing MySQL and phpMyAdmin on
Windows (for IIS only)
Setting up PHP for Mac OS X
Defining a PHP site in Dreamweaver
CS5
Creating a MySQL database and user
account
Connecting to the database
Created
30 April 2010
Page tools
Was this helpful?
Yes No
By clicking Submit, you accept the
Adobe Terms of Use.

Thanks for your feedback.
User level
Beginning
Required products
Dreamweaver CS5 (Download trial)
Sample files
php_test.zip (25 KB)
This tutorial describes how to set up a development environment on a Windows or a Macintosh computer for building
PHP web applications with Adobe Dreamweaver and a MySQL database server.
Setting up a PHP development environment for Dreamweaver requires a web server (such as Apache or IIS), PHP, and a
MySQL database. Although you can install all three separately, it's usually much simpler to use an all-in-one solution, such
as XAMPP for Windows or MAMP for Mac OS X.
Note: PHP can be used with most database systems. However, Dreamweaver's PHP server behaviors support only
MySQL.
This setup tutorial shows you how to complete the following tasks:
Install and run a PHP-enabled web server on your local computer
Install the MySQL database server on your local computer
Define a PHP site in Dreamweaver CS5
Import data into MySQL and create a MySQL user account for your web application
Connect to a sample database
Setting up PHP for Windows
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 and the MySQL database. It's also useful to have phpMyAdmin, a graphical interface to MySQL.
All three components are open source software that you can use for developing, testing, and deploying web
applicationsand they are free!
You can install each one independently, but the quickest and easiest way is to use an all-in-one solution. The one chosen
for this tutorial is XAMPP. If you already have a working PHP/MySQL environment, or want to use a different all-in-one
installer, such as WampServer (http://www.wampserver.com/en/), go straight to Defining a PHP site in Dreamweaver.
If you're a Mac user, see Setting up PHP for Mac OS X.
Before you start
XAMPP installs the Apache web server, which listens for requests on port 80. This is the default port used by most web
servers, including Microsoft Internet Information Services (IIS). Only one web server at a time can listen on port 80.
If you have installed IIS on your computer to develop with ASP or ASP.NET, you must stop the IIS web server before
installing XAMPP. Alternatively, you can install PHP in IIS using the Microsoft Web Platform Installer as described in
Setting up an ASP development environment for Dreamweaver. However, if you install PHP in IIS, you need to install
MySQL and phpMyAdmin separately; see Installing MySQL and phpMyAdmin on Windows (for IIS only) for more
details.
Installing XAMPP
Installing and configuring XAMPP is usually quick and trouble-free, but things do sometimes go wrong. If you run into
problems, the best place to get help is in the XAMPP forum.
You must be logged into Windows in an administrator account.
1. Go to the Apache Friends website and download XAMPP for Windows. Choose the Basic package self-extracting
RAR archive.
2. 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.
3. 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.
Requirements
9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection
www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 2/18
After you have set the options, you should see a message telling you that XAMPP is ready. This is followed by a screen
with a short menu (see Figure 1). Type 1 and press Enter to start the XAMPP Control Panel. Then type x and press Enter
to close the Command Prompt window.
Figure 1. The final stage of the XAMPP installation process involves setting options in a Command Prompt window.
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 (see Figure 2).
Figure 2. The XAMPP Control Panel confirms that Apache and MySQL are running.
Note: If a Windows Security alert pops up asking whether to keep blocking the program mysql or apache, choose
Unblock for both programs.
Note the following in case of errors:
If Apache fails to start, make sure you are logged into your computer with an Administrator account. Selecting the
Run As Administrator option usually does not give sufficient privileges to start the web server.
If Apache reports an error on startup, double-click the file C:\xampp\apache\logs\error.log in Windows Explorer,
and scroll to the bottom of the file to read any error messages.
The error log for MySQL is located in the C:\xampp\mysql\data folder. It's in a file that uses the same name as your
computer followed by an .err file name extension. To open it, double-click its icon, and select Notepad when
prompted to select a program to use.
If you want to enable Apache or MySQL as Windows services so they start automatically, select the Svc check box
alongside each one. (FileZilla and Mercury are FTP and mail programs, which are not required to develop with PHP in
Dreamweaver. They are not covered in this article.)
9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection
www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 3/18
Securing the database
To secure the database:
1. Launch a browser and type http://localhost/ into the address bar.
2. If everything has been correctly installed, you should see a web page offering a choice of languages. Select the
language you want to use.
3. The menu on the left of the welcome screen that follows (see Figure 3) gives you web-based access to various parts
of XAMPP, including security configuration options.
Figure 3. The XAMPP welcome screen appears after you select a language to use.
4. 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.
5. This displays the security console (see Figure 4), which prompts you to create a password for the MySQL superuser,
root.
Note: Even if you are the only person using the computer, it's good practice to password protect the MySQL
database.
Figure 4. Set the MySQL root password.
6. Type your chosen password in both fields. It can contain special characters, but should not have any spaces.
7. Immediately below the password fields is a pair of radio buttons that determine how phpMyAdmin connects to
MySQL as the root superuser. The default is to store it in a cookie. This is fine for a local development environment.
8. You are also asked whether to set a random password for the pma user. The default Yes is fine.
9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection
www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 4/18
9. If you're worried about forgetting the root superuser password, you can select the check box just above the
Password Changing button to store it in a plain text file (mysqlrootpassword.txt). How much of a security risk this
represents depends on who else has access to your computer.
10. After making your choices, click the Password Changing button.
Testing the PHP installation
After installing XAMPP and securing the database, it's a good idea to test the PHP installation:
1. Close the XAMPP security window or tab, and return to the welcome screen (see Figure 3).
2. 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 (see Figure 5).
Figure 5. phpinfo() displays PHP configuration information.
Although this screen might feel like information overload at this stage, it contains a wealth of information about your PHP
setup. Return to this screen whenever you need to check how PHP is configured.
Note: You can display the same information by creating a PHP file containing the following script and loading it into a
browser:
<?php phpinfo(); ?>
Testing MySQL and phpMyAdmin
Follow these steps to verify your MySQL and phpMyAdmin setup:
1. Click the phpMyAdmin link in the Tools section of the menu on the left of the XAMPP welcome screen.
2. This loads the login page for phpMyAdmin (see Figure 6). Type root as the username, type the root password you
created earlier, and click Go.
9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection
www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 5/18
Figure 6. Log into phpMyAdmin.
After successfully logging in, you'll see the main phpMyAdmin screen (see Figure 7).
Figure 7. Use phpMyAdmin to create and administer databases in MySQL.
Congratulations! You now have a working installation of PHP, MySQL, and phpMyAdmin.
The next section covers instaling MySQL and phpMyAdmin separately for use with IIS, so you can skip directly to Defining
a PHP site in Dreamweaver CS5 or return to Part 1 of the tutorial series Creating your first dynamic site in Dreamweaver
(if that's where you started).
Installing MySQL and phpMyAdmin on Windows (for IIS only)
If you are using PHP in IIS, you need tinstall MySQL and phpMyAdmin separately.
Note: These instructions only if you are using IIS as your web server. MySQL and phpMyAdmin are already installed in
XAMPP and WampServer.
1. Download the Windows Essentials installer from the Windows Downloads category on the MySQL download page.
2. Double-click the installer file, and follow the onscreen instructions. Choose Typical Install.
3. At the end of the installation process, select the option tconfigure the MySQL server, and click Finish.
4. In the MySQL Server Instance Configuration Wizard, make the following choices:
For configuration type, select Detailed Configuration.
For server type, select Developer Machine.
For database usage, select Multifunctional Database.
For the number of concurrent connections, select Decision Support (DSS)/OLAP.
For networking options, accept the default settings.
For the default character set, accept the default setting.
For the Windows options, select both options: Install As Windows Service and Include Bin Directory in Windows
Path.
9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection
www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 6/18
For security options, enter a root password and confirm it.
5. Click Execute tconfigure MySQL.
Installing phpMyAdmin separately (for IIS only)
The next step is tinstall phpMyAdmin, a graphic front end for MySQL. Since phpMyAdmin is PHP based, installation is a
straightforward three-step process: download the files, unzip them to the website in your local testing environment, and
create a simple configuration file.
1. Download the latest stable version of phpMyAdmin from the phpMyAdmin website.
2. Unzip the downloaded file. It will extract the contents ta folder called phpMyAdmin-x.x.x, where x represents the
version number.
3. Rename the folder phpmyadmin.
4. Cut and paste (i.e. move) the phpmyadmin folder (and all its contents) in the IIS server document root:
C:\inetpub\wwwroot.
5. Create a new subfolder called config within the phpmyadmin folder.
6. Open a browser, and type the following in the address bar: http://localhost/phpmyadmin/setup/index.php.
7. Ignore any warning about the connection not being secure. This warning is intended for server administrators
installing phpMyAdmin on a live Internet server.
8. Click the Add button in the Servers section. This loads a form with most of the necessary information already filled in.
Verify the following settings:
Server hostname: localhost
Server port: Leave blank
Server socket: Leave blank
Connection type: tcp
Authentication type: config
User for config auth: root
Password for config auth: Type your MySQL root password
9. Scroll down the Actions field, and click Add. You'll see twbuttons labeled Add. Make sure you click the one that has a
Cancel button alongside.
The next screen will probably warn you that you didn't set up a phpMyAdmin database, syou won't be able tuse all
the phpMyAdmin features. This is not important. You can set up one later if you decide tuse the advanced features of
phpMyAdmin.
10. Scroll down the Configuration section near the bottom of the page, and click Save.
11. Open the config folder in Windows Explorer. You should see a new file called config.inc.php. Move it the main
phpmyadmin folder.
12. Delete the config folder.
13. Type http://localhost/phpmyadmin/ in your browser address bar and load phpMyAdmin (see Figure 7).
You now have a PHP development environment. The next page describes how to set up PHP on a Mac, so you can skip it
and proceed directly to Defining a PHP site in Dreamweaver CS5.
Setting up PHP for Mac OS X
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 and the MySQL database. It's also useful to have phpMyAdmin, a graphical interface to MySQL.
All three components are open source software that you can use for developing, testing, and deploying web applications.
What's more, they're free.
The Apache web server and PHP are preinstalled in Mac OS X. However, they're not enabled by default. Moreover, the
preinstalled version of PHP lacks a lot of useful features, and you need to install and configure MySQL separately. Unless
you're very comfortable working with the command line in Terminal, it's much easier to install the all-in-one solution
MAMP.
This section describes how to install MAMP on your Mac. This installs the Apache web server, MySQL, and phpMyAdmin
in a single operation.
If you already have working versions of Apache, MySQL, and phpMyAdmin, there is no need to install MAMP. Go straight
to Defining a PHP site in Dreamweaver CS5.
Note: You can also purchase a license for a commercial add-on called MAMP PRO. This makes it easier to organize your
sites. However, the free version is perfectly adequate for developing PHP pages with Dreamweaver, so MAMP PRO is not
9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection
www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 7/18
covered here.
If you're a Windows user, see Setting up PHP for Windows.
Before you start
Instead of using the preinstalled versions of Apache and PHP, MAMP installs separate versions in a different location on
your hard disk. This makes it easier to uninstall everything by simply dragging the MAMP folder to the trash if you decide
you no longer want MAMP on your computer. MAMP also avoids conflicts with the preinstalled version of Apache by
using a non-standard port (8888) to listen for requests for web pages.
To make it easier to deploy your PHP pages on the Internet, it's a good idea to configure MAMP to use the standard port
for web servers (80). Instructions for how to do this are given later, but you should first check that the preinstalled
versions are not running.
1. Open System Preferences, and select Sharing in Internet & Network.
2. Make sure that Web Sharing is not selected.
As long as MySQL has never been installed on your computer, you're good to go.
Note: Installing MAMP is usually very quick (just a couple of minutes) and trouble-free. However, things do sometimes go
wrong. If you run into difficulties, the best place to look for help is in the MAMP forum.
Installing MAMP on your Mac
To install MAMP on your Mac:
1. Go to the MAMP download page and select the link for MAMP & MAMP PRO. This downloads a disk image that
contains both the free and commercial versions.
2. When the download completes, you will be presented with a license agreement. You must click Agree to continue
with mounting the disk image.
3. When the disk image is mounted, drag the MAMP folder onto the shortcut icon for Applications as indicated by the
arrow (see Figure 8).
Figure 8. Install MAMP from the disk image.
4. Verify that MAMP has been copied to your Applications folder, and eject the disk image.
For the purposes of this article, you need to install only the free version of MAMP. The commercial version is an add-on
that you can add later if you want to use its advanced features. To learn more about the commercial version, visit the
MAMP PRO website.
Testing and configuring MAMP
To test and configure MAMP:
1. Double-click the MAMP icon in Applications/MAMP.
9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection
www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 8/18
2. After a few moments, your default browser should launch and present you with a page welcoming you to MAMP.
Note that the URL in the browser address bar begins with http://localhost:8888. The :8888 string after localhost
indicates that the web server is listening for requests on the non-standard port 8888.
3. Minimize the browser and locate the MAMP control panel, which should be running on your desktop. The green
lights alongside Apache Server and MySQL Server indicate that both servers are running (see Figure 9).
Figure 9. The MAMP control panel shows the status of the Apache and MySQL servers.
4. Click Preferences, and select Ports at the top of the panel that opens. The panel shows that Apache and MySQL are
running on ports 8888 and 8889, respectively (see Figure 10).
Figure 10. Change the MAMP ports.
5. Click Set To Default Apache And MySQL Ports.
The numbers change to the standard ports: 80 for Apache and 3306 for MySQL. This will make your development
with Dreamweaver easier.
6. Click OK and type your Mac password when prompted.
MAMP stops and restarts both servers.
Note: This is the most likely place for something to go wrong. If any other program is using port 80, Apache won't
restart. If that happens, check that Web Sharing is not selected in Internet & Sharing in System Preferences. Another
possibility is that Skype is using port 80. You can change the port in the Advanced section of Skype Preferencestry
42815 as the incoming port. If you can't find what's preventing Apache from using port 80, open the MAMP
preference panel, and click Reset MAMP ports.
7. When both lights are green again, click Open Start Page. This reloads the MAMP welcome page into your browser.
This time, the URL is likely to have :80 after localhost. Because port 80 is the default, the addition of :80 is
unnecessary, so it doesn't matter if it's missing.
You only need the colon followed by a number when you use nonstandard ports.
8. Click the phpinfo link in the MAMP menu. You should see a page showing PHP configuration information (see Figure
11).
9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection
www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 9/18
Figure 11. PHP configuration information shows system details and more.
Congratulations! You have a working installation of PHP, MySQL, and phpMyAdmin. Although this screen might feel like
information overload at this stage, it contains a wealth of information about your PHP setup. Return to this screen
whenever you need to check details of the way PHP is configured.
Note: You can display the same information by creating a PHP file containing the following script and loading it into a
browser:
<?php phpinfo(); ?>
Now that you have a PHP testing environment on your computer, you can proceed to Defining a PHP site in
Dreamweaver so you can start developing.
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. The following instructions
assume you have established a local testing environment on your computer as described in the preceding sections.
In theory, you can locate your PHP files anywhere on your computer, and Dreamweaver will copy them to the testing
server when you use Live view or Preview In Browser. However, this results in two identical copies of every file. Instead it's
common practice to store project files in a folder inside the document root of the testing server, which is what you'll do in
this tutorial.
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.
Here are the default locations for common PHP setups:
XAMPP: C:\xampp\htdocs
IIS: C:\inetpub\wwwroot
WampServer: C:\wamp\www
MAMP: /Applications/MAMP/htdocs
The URL for the document root is http://localhost/.
Note: If you are using the MAMP default ports, use http://localhost:8888/ for the URL.
Specifying a working folder
To specify a working folder:
1. In Dreamweaver, select Site > New Site.
9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection
www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 10/18
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 (Choose on a Mac).
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.)
Figure 12. 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).
9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection
www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 11/18
Figure 13. The basic settings for the testing server include the Server Folder and the Web URL.
Note: If you're using the MAMP default ports, the Web URL should be http://localhost:8888/php_test/.
7. Select the Advanced button at the top of the dialog box. This reveals the options for both a remote server and a
testing server.
8. For the Server Model (in the Testing Server section) select PHP MySQL (see Figure 14).
Figure 14. Set the Server Model for the testing server to PHP MySQL.
9. Click Save.
10. 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).
9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection
www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 12/18
Figure 15. Make sure the Testing check box is selected.
11. 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.
3. 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).
Figure 16. The dynamic code is represented in Design view by a gold shield.
4. Click the Live View button. The gold shield should be replaced by the current time (see Figure 17).
Figure 17. The PHP code is processed by the web server and displayed in Live view.
Note that the value in the Address text box now displays the Web URL rather than the physical location of the file.
Didn't work?
If the time did not display in Live view, check the following:
Is the web server (Apache or IIS) running? Unless you have configured the server to run automatically, it needs to be
9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection
www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 13/18
started manually before you can process PHP pages.
Does the Web URL point to the same location as the Server Folder (see Figure 13)? The server's document root
(htdocs, wwwroot, or www, depending on your PHP setup) is the equivalent of http://localhost/. If your site is in a
subfolder of the document root, you need to add the subfolder's name to the URL.
If you're using the MAMP default ports, have you added :8888 after localhost?
Is security software blocking access to ports 80 and 3306 (or ports 8888 and 8889 if you're using the MAMP
defaults)?
Using the sample files
The PHP site is now defined and working. The next step is to add the sample files to the test site in preparation for
connecting to a database.
If you haven't already done so, download the sample files for this tutorial, unzip them, and copy them to the php_test
folder in your server's document root. You should now see the sample files in the Files panel (see Figure 18). You may
need to click the Refresh icon at the top of the Files panel to see the files.
Figure 18. The sample files for testing the database connection are visible in the Files panel.
Creating a MySQL database and user account
MySQL is not a single database, but a database management system. You create individual databases within MySQL. The
superuser, root, has complete control over all databases, so it's necessary to set up user accounts with restricted
privileges to prevent unauthorized users gaining access to other people's data.
In this section, you'll use the phpMyAdmin front end to MySQL to create a database, import sample data, and create a
MySQL user account. The instructions assume that you have installed XAMPP on Windows, MAMP on a Mac, or that you
have created your own PHP testing environment with a web server, PHP, MySQL, and phpMyAdmin.
Creating a new database and importing data
To perform this task:
1. Verify that your web server and the MySQL server are running.
2. Start phpMyAdmin. In most cases, you can do this by typing http://localhost/phpmyadmin/ into your browser
address bar.
If you're using MAMP in Mac OS X, use http://localhost/MAMP/ or http:localhost:8888/MAMP/, and then click
the link for phpMyAdmin.
3. If you installed XAMPP in Windows, type root as the username, and then your MySQL root password when
prompted.
You should see the phpMyAdmin welcome screen (see Figure 19).
9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection
www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 14/18
Figure 19. The phpMyAdmin main screen provides access to MySQL.
Note: The default list of databases shown in the menu on the left of the screen is slightly different in XAMPP and MAMP,
but this is not important.
4. Type php_test in the text box labeled Create New Database and click Create.
Note: When choosing names for databases and database columns (fields), do not use spaces or hyphens; use only
alphanumeric and underscore characters (for example, feedback_demo). Although phpMyAdmin accepts spaces
and hyphens, they require special handling and are likely to cause problems. It's also a good idea to use lowercase
throughout, because the Windows version of MySQL automatically converts names to lowercase and treats them as
case-insensitive. Most PHP sites are hosted on Linux servers, which are case-sensitive. If your names include
uppercase characters, everything will break when you upload your web application from Windows to a Linux server.
Note: You can ignore the Collation setting, unless you are using a language other than English. Collation determines
the sort order of records. The default setting is fine for English.
5. When phpMyAdmin reports that the php_test database has been created, click the Import tab at the top of the page.
6. In the File To Import section, click Browse alongside the Location Of The Text File text box and select php_test.sql
from the assets folder in your PHP test site.
7. Click Go at the bottom of the page. This imports sample data into the database.
8. Leave phpMyAdmin open, as you will continue using it in the next section.
Creating a MySQL user account
The root superuser should be used only for administrative tasks inside phpMyAdmin, because it has the power to wipe
out all of your data. After data has been deleted, you cannot restore it! There is no equivalent of the Windows Recycle Bin
or Mac Trash in MySQL. So, the next task is to create a MySQL user account with restricted privileges. Follow these steps
to create an account that has access only to the php_test database:
1. Click the icon that looks like a little house at the top left of the phpMyAdmin screen to return to the original welcome
screen (see Figure 19).
2. Click the Privileges tab at the top of the welcome page.
Note: Many of the features in phpMyAdmin are context-sensitive. There is a Privileges tab at the top of every screen,
but to create a new user account, you must return to the welcome page and click the Privileges tab there.
3. Click Add A New User (located about halfway down the page).
4. In the User Name text box, type phptestuser.
5. Select Local as the Host. This enters localhost in the text box alongside, restricting the user to your local test
environment.
6. Type a password in the Password field, and retype it in the field immediately below.
7. Leave the rest of the page unchanged, and click Go at the bottom of the page.
The next screen confirms that the new user has been added. The Global privileges section gives the user account the
same privileges on all databases. For the purposes of this tutorial, you're going to limit the user to the php_test
database.
8. Scroll down to the Database-specific Privileges section and select the php_test database (see Figure 20).
9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection
www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 15/18
Figure 20. Limit the MySQL user account to a specific database.
Note: The underscore in the database name is preceded by a backslash. In certain circumstances, the underscore can be
used as a wildcard character in MySQL, and the backslash is needed here to ensure that the underscore is treated as a
literal character. However, this is an exceptional case. Normally, you should not precede the underscore in database,
table, or column names with a backslash.
9. On the next page you can set the user's privileges for the selected database. For a web application, only four
privileges are normally required: SELECT, INSERT, UPDATE, and DELETE. Select them and click Go (see Figure 21).
Figure 21. Set SELECT, INSERT, UPDATE, and DELETE user privileges for a web application.
You now have a MySQL user account ready to access the php_test database. In the next section, you'll learn how to
create a MySQL connection in Dreamweaver.
Connecting to the database
The sample files contain include comments.php, which queries the php_test database and displays the results. Dynamic
text objects in the Customer Comments section in the center of the page (see Figure 22) indicate where the results will be
shown. Before you can view the results, you need to create a connection to the database.
9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection
www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 16/18
Figure 22. The sample PHP page contains dynamic text objects.
1. Open comments.php. You must have a PHP page open in the Document window to create a MySQL connection.
2. In the Databases panel (choose Window > Databases), click the Plus (+) button on the panel and select MySQL
Connection.
The MySQL Connection dialog box appears.
3. Type connTest as the connection name.
4. For the MySQL Server, type localhost.
If you are using the MAMP default ports on a Mac, use localhost:8889.
5. For the User Name, type phptestuser.
6. Type the password you chose for the phptestuser account in the Password field.
7. For the Database, type php_test.
Note: You don't need to precede the underscore with a backslash here. It was inserted by phpMyAdmin in the
previous section (see Figure 20) only because phpMyAdmin uses a query that permits wildcard characters.
8. Click Test.
Dreamweaver attempts to connect to the database. If the connection fails, do the following:
Double-check the server name, user name, and password.
Check the settings for the folder Dreamweaver uses to process dynamic pages (see Specifying a Testing Server
for Dreamweaver).
Verify that the web and MySQL servers are both running.
Temporarily disable any firewall or security program. If the connection works, you need to configure the security
program to permit communication between Dreamweaver and MySQL.
9. Click OK. The new connection appears in the Databases panel.
10. Expand the connTest connection, and then expand the Tables branch. You'll see the comments table in the database,
which you can expand to reveal the details of the table columns (see Figure 23).
9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection
www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 17/18
More Like This
Creating a Spry XML data set
Which server-side technology should I choose?
Exchanging data using the Spry framework for Ajax and PHP
Managing multiple subscriptions in PHP
Creating custom server behaviors and Dreamweaver extensions
Creating user-defined functions for ColdFusion 8 in Dreamweaver CS4
Building your first dynamic website Part 1: Setting up the site and database
Creating master and detail ColdFusion pages
Creating a ColdFusion upload page in Dreamweaver CS4
Advanced design template for jQuery Mobile
Tutorials and samples
Figure 23. The Databases panel shows the table columns.
11. Click the Live View button. The dynamic text objects in comments.php should be replaced by data retrieved from
the database (see Figure 24).
Figure 24. The data from the database is 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.
Where to go from here
This tutorial has shown you how to set up a PHP development environment, define a PHP site, and connect to a MySQL
database. Defining the site and testing server, and establishing a MySQL connection are fundamental to developing PHP
web applications in Dreamweaver. You are now set to start developing dynamic websites with PHP in Dreamweaver.
For more articles and tutorials on developing for PHP using Dreamweaver, visit the Web application development page
in the Dreamweaver Developer Center.
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
9/10/13 Setting up a PHP development environment for Dreamweaver | Adobe Developer Connection
www.adobe.com/devnet/dreamweaver/articles/setup_php.html#articlecontentAdobe_numberedheader 18/18
Tutorials
Using the SSI extension in Dreamweaver
to create page headers
Creating your first website Part 3
Creating your first website Part 4
Creating your first website Part 6
Samples
Responsive design with jQuery marquee
Customizable starter design for jQuery
Mobile
Customizable starter design for HTML5
video
Customizable starter design for
multiscreen development