TechSpace Knowledgebase
Search:     Advanced search
Browse by category:
Contact Us

Configuring PHP Development Environment in Windows

Views: 646
Votes: 0
Posted: 27 Mar, 2016
by: Wonglangga S.
Updated: 23 Apr, 2016
by: Wonglangga S.

This tutorial shows you two ways of configuring your PHP development environment on the Windows operating system. The first and most convenient way is to install and configure an AMP (Apache, MySQL, PHP) package. This tutorial shows you how to install the XAMPP package. The second way is to install and configure each component separately.

Contents

Content on this page applies to NetBeans IDE 7.2, 7.3, 7.4 and 8.0

To follow this tutorial, you need the following software and resources.

Software or Resource Version Required
NetBeans IDE PHP download bundle
A PHP engine Version 5. Included in XAMPP-Windows.
A web server Apache HTTP Server 2.2 is recommended.
Included in XAMPP Windows.
A database server MySQL Server 5.0 is recommended.
Included in XAMPP Windows.
A PHP debugger (optional) XDebug 2.0 or later.

Typically, development and debugging is performed on a local web server, while the production environment is located on a remote web server. Setting up a remote web server is described in Deploying a PHP Application on a Remote Web Server Using the NetBeans IDE. This tutorial has you set up a local web server. PHP support can be added to a number of local web servers (IIS, Xitami, and so on), but most commonlyApache HTTP Server is used. Apache HTTP server is included in the XAMPP AMP package used in this tutorial. For information on installing and configuring Apache HTTP server standalone, click here.

Required Software

To create, run, and debug your PHP projects you need the following software:

  • The NetBeans IDE for PHP. Downloads are available here.
  • A web server. Typically development and debugging is performed on a local web server, while the production environment is located on a remote web server. The current version enables using a local server. Using a remote server with FTP access will be supported in future versions. PHP support can be added to a number of web servers (IIS, Xitami, and so on), but most commonly Apache HTTP Server is used. Click here for information on how to install and configure Apache 2.2.
  • The PHP engine. The supported version is PHP5. Downloads are available here.
  • The PHP debugger. The NetBeans IDE for PHP allows you to use XDebug, but using a debugger is optional. The recommended version is XDebug 2.0 or higher as it is compatible with PHP5.
  • A database server. You can use various database servers while one of the most popular ones is the MySQL server. Downloads are available here
    Note: The recommended version of the product is MySQL Server 5.0. The provided documents describe the work with this version.

After the installation, you need to set up the environment that all the software components work properly with each other.

You can use a Package, that contains the required software, or install each component separately.

Using an AMP Package

To have all the configuration settings for the PHP engine, the Apache HTTP Server, and the MySQL database server specified automatically, use an AMP package. This tutorial gives instructions only for the XAMPP-Windows package. For help with the WAMP package, please see the NetBeans XDebug Wiki.

Installing and Configuring the XAMPP Package

The section describes how to download, install, and configure the XAMPP package.

Warning: Do NOT use XAMPP 1.7.0. There are significant problems with XDebug in this version. Use version 1.7.1 or later, where these problems are fixed.

Note: Starting with XAMPP 1.7.2, XAMPP comes with PHP 5.3, not PHP 5.2.x. NetBeans IDE for PHP version 6.7.x does not support the new PHP 5.3 functions. NetBeans IDE for PHP 6.8, currently available as a development build, fully supports PHP 5.3. Also note that Xdebug installation differs between PHP 5.2.x and PHP 5.3.

  1. Download the XAMPP installer package. (XAMPP Lite does not include XDebug.)
  2. When the download is completed, run the .exe file.

    On Microsoft Vista, the User Access Control feature blocks the PHP installer from updating the Apache httpd configuration. Disable UAC while you are installing XAMPP. See Microsoft support for more information.

  3. You are given the option to install the Apache server and the MySQL database server as services. If you install the Apache Server and MySQL as services, you will not have to start them manually through the XAMP Control Panel. Note that you have the option to install or uninstall these services in the XAMPP Control Panel.
  4. If you are using the self-extracting archive, after the archive is extracted, run the file setup-xampp.bat to configure the components of the package. (The XAMPP installer runs this file automatically.)
  5. After configuration, open the XAMP Control Panel. (You can open it manually by running the file XAMPP_HOME/xampp-control.exe or from the Xampp Control Panel icon that is automatically placed on your desktop.) When you open the XAMPP Control Panel, note that the modules that are installed as services are already running.

    Warning: On Windows Vista sometimes xampp-control.exe will not run. You can run xampp-start.exe instead.

    Warning: The winmysqladmin.exe file, which is launched by the Admin button for MySQL, does not work. A cascade of error messages appears, which can only be stopped by manually terminating the winmysqladmin process. You cannot launch winmysqladmin.exe from the command line, either. See http://bugs.xampp.org/view.php?id=71.

    XAMPP Control Panel
  6. The Svc checkboxes indicate that a module is installed as a Windows service and will start automatically on system startup. You can install or uninstall Windows services by selecting or unselecting the Svc checkbox. Uninstalling a Windows service does not uninstall the module, but it does require you to start the module manually. The XAMPP control panel includes buttons for stopping and starting modules and opening their administration consoles.

Checking XAMPP Installation

  1. Run your browser and enter the following URL: http://localhost. The XAMPP welcome page opens:
    XAMPP welcome page indicates that Apache is running
  2. To ensure that the Apache and MySQL servers have been installed as system services, restart your operating system, run the browser, and enter the http://localhost URL again. The XAMPP welcome page opens. Note that the XAMPP welcome page includes a menu in the left margin through which you can check the status of XAMPP components and run phpinfo(), among other useful features. phpinfo()returns a screen with configuration information about your XAMPP components. 
    Configuration information table returned by phpinfo()

Installing and Enabling the XDebug Debugger

You need to configure your PHP stack to use XDebug. The process differs if you are using XAMPP 1.7.1, which bundles PHP 5.2.6, or XAMPP 1.7.2, which bundles PHP 5.3.

Many users have experienced difficulties in getting XDebug to work on their systems. Please see our wiki and the NetBeans PHP Editor Users' Forum for assistance.

XDebug on XAMPP 1.7.1 (PHP 5.2)

You must download XDebug, place the .dll file in your php extensions directory, and configure php.ini to find and use this file.

  1. Download the latest thread-safe XDebug compatible with your version of PHP. The download links are listed under Releases. Copy the .dll file to your XAMP_HOME/php/ext directory. (XAMPP_HOMErefers to your XAMPP or XAMPP Lite installation directory, such as C:\Program Files\xampp or C:\xampplite.)
  2. Locate and open the active php.ini file for your XAMPP. This is located by default in the XAMPP_HOME/apache/bin directory. Confirm which php.ini file is active by running phpinfo() and searching for Loaded Configuration File.
  3. Because Zend optimizer blocks XDebug, you need to disable Zend optimizer. In the active php.ini file, locate the following lines and delete them or mark as comments (To be safe, search for and comment out all properties related to Zend):
    [Zend]
    ;zend_extension_ts = "C:\Program Files\xampp\php\zendOptimizer\lib\ZendExtensionManager.dll"
    ;zend_extension_manager.optimizer_ts = "C:\Program Files\xampplite\php\zendOptimizer\lib\Optimizer"
    ;zend_optimizer.enable_loader = 0
    ;zend_optimizer.optimization_level=15
    ;zend_optimizer.license_path =
    
  4. To attach XDebug to the PHP engine, uncomment the following lines in the php.ini files (directly beneath the [Zend] section, add them if not there). Some additional notes have been added.
    [XDebug]
    ; Only Zend OR (!) XDebug
    zend_extension_ts = "./php/ext/php_xdebug<-version-number>.dll"
    ; XAMPP and XAMPP Lite 1.7.0 and later come with a bundled xdebug at <XAMPP_HOME>/php/ext/php_xdebug.dll, without a version number.
    xdebug.remote_enable=1
    xdebug.remote_host=127.0.0.1
    xdebug.remote_port=9000
    ; Port number must match debugger port number in NetBeans IDE Tools > Options > PHP
    xdebug.remote_handler=dbgp
    xdebug.profiler_enable=1
    xdebug.profiler_output_dir="<XAMPP_HOME>\tmp"
    
      

    Set the xdebug.remote_enable property to 1, not "true" or any other value.

    Note: Make sure the paths you specify match the location of the corresponding files as determined during your installation.

  5. Save php.ini.
  6. Run the XAMPP Control Panel Application and restart the Apache server.
See our wiki and the XDebug documentation for more information on how to configure XDebug.

Xdebug on XAMPP 1.7.2 (PHP 5.3)

XAMPP 1.7.2 comes bundled with the appropriate Xdebug .dll file. You only have to configure php.ini to use it. Note that all Xdebug settings have text explaining them.

  1. Locate and open XAMPP_HOME\php\php.ini for editing. This is the only php.ini file in XAMPP 1.7.2.
  2. Find and uncomment the line zend_extension = "XAMPP_HOME\php\ext\php_xdebug.dll".
  3. Find and uncomment the line xdebug.remote_host=localhost. Change the value of the setting from localhost to 127.0.0.1.
  4. Find and uncomment the line xdebug.remote_enable = 0. Change 0 to 1.
  5. Find and uncomment the line xdebug.remote_handler = "dbgp".
  6. Find and uncomment the line xdebug.remote_port = 9000.
  7. Save php.ini.
  8. Run the XAMPP Control Panel Application and restart the Apache server.

See our wiki and the XDebug documentation for more information on how to configure XDebug.

Installing the Components Separately

Apache HTTP Server

  1. Download the Apache2 HTTP server.
  2. Run the installation file .msi. The installation wizard starts. Follow the instructions.

    On Microsoft Vista, do not install the Apache Server to the default location, which is in Program Files. All files in Program Files are write-protected.

  3. When the installation is completed, restart the Apache server.
  4. To check that the installation is successful, run the browser and enter the following URL:
      http://localhost/
    The Apache welcome test page opens: 
    Apache web server test page indicates that Apache is running

Troubleshooting

By default, the Apache server listens to port 80. This port can be already used by other services, for example Skype. To solve the issue, change the port which the server listens to:
  1. Open the Apache web server configuration file httpd.conf. By default the file is located in C:\Program Files\Apache Software Foundation\Apache<version>\conf\
  2. Locate the line Listen 80 and change the port number, for example 8080. Save the file.
  3. Restart the Apache web server.
  4. To check that the web server works, run the browser and enter the URL and specify the port number explicitly: http://localhost:8080

You can also stop the processes that possibly listen to port 80. In the Task Manager, select the relevant file name and click End Process.

Find more information on installing and configuring the server here.

PHP Engine

  1. Download the Windows binary installer for the PHP5 version of your choice.

    Important: If there is no installer available for the version of PHP you want to install, you have to install it manually from the .zip file. See Manual Instruction Steps in the php.net documentation.

  2. When the download is complete, run the .msi installation file. The installation wizard starts.
  3. On the Apache Configuration Directory panel, specify the directory where the httpd.conf file is located, the default setting is C:\Program Files\Apache Software Foundation\Apache<version>\conf\. The PHP processing will be enabled automatically.
  4. If you want to use the MySQL database server, choose the Complete installation option or select the MySQL and MySQLi items in the Extensions list.
  5. After the installation is completed, restart the Apache server.
  6. To check that the PHP engine has been installed successfully and PHP processing has been enabled in the Apache configuration:
    • Open Notepad or another text editor. Create a file and type the following text:
      <?php 
           echo "PHP has been installed successfully!";
      ?>
    • Save the file in the htdocs folder as test.php. The default path is C:\Program Files\Apache Software Foundation\Apache<version>\htdocs\test.php
    • Run the browser and enter the following URL: http://localhost:<port>/test.php. The following page opens:
      PHP test page indicates that the PHP engine is enabled

Troubleshooting

If the page does not open:
  1. Restart the Apache server.
  2. Check that the Apache server configuration file httpd.conf contains the following lines:
      AddType Application/x-httpd-php .php 
      LoadModule php5_module "c:/php/sapi/php5apache2_2.dll"
  3. If the lines are missing, add them, save httpd.conf, and restart Apache.
  4. Refresh the http://localhost:<port>/test.php page.

MySQL Database Server

Find detailed information on installing and configuring the MySQL database server.

XDebug

  1. Download XDebug.
  2. Install XDebug into the php/ folder. You will need the path to it to configure your environment.

Setting Up the Environment

  1. If your installation follows the default settings, PHP processing will be enabled automatically.
  2. To attach XDebug to the PHP engine, locate the php.ini file and add the following lines to it:

    For a thread-safe PHP 5.2 engine:

    zend_extension_ts="<path to the php folder>/php_xdebug-<version-number>.dll"
    xdebug.remote_enable=1

    For a non-thread-safe PHP 5.2 engine:

    zend_extension_nts="<path to the php folder>/php_xdebug-<version-number>.dll"
    xdebug.remote_enable=1

    For any PHP 5.3 engine:

    zend_extension="<path to the php folder>/php_xdebug-<version-number>.dll"
    xdebug.remote_enable=1

    Some users also find that they need to include the following lines, although other users do not:

    xdebug.remote_host=127.0.0.1
    xdebug.remote_port=9000
    ; Port number must match debugger port number in NetBeans IDE Tools > Options > PHP
    xdebug.remote_handler=dbgp
    

    Click here for more information on how to configure XDebug.

    Note: Make sure the paths you specify match the names and locations of the corresponding files as determined during your installation.

  3. To be sure that previously installed PHP engine supports using the MySQL database server:
    1. Click Start > Control Panel.
    2. On the Control Panel, choose Add or Remove Programs.
    3. On the Add or Remove Programs panel, select the PHP <version number> area and click Change. The PHP Setup Wizard starts. Click Next.
    4. On the Change, repair or remove installation panel, choose Change and click Next.
    5. On the Web Server Setup panel, choose the version of the Apache server - in our example it is Apache 2.2.x Module. Click Next.
    6. On the Apache Configuration Directory panel, specify the directory where the Apache configuration file httpd.conf is located. Click Next.
    7. On the Choose Items to Install panel, expand the Extensions node and choose the MySQL and MySQLi items. Click Next.
    8. On the Ready to change PHP <version number> panel, click Change.
    9. On the Completed the PHP <version number> Setup Wizard panel, click Finish.
Others in this Category
document How to Clear Your Computer’s CMOS to Reset BIOS Settings
document Install Hyper-V and create a virtual machine
document Configure DHCP Using Policy-based Assignment
document What Are Domains and Forests?
document Phoenix ISA/MCA/EISA BIOS Beep Codes
document How to make a self extracting archive that runs your setup.exe with 7zip -sfx switch
document Configuring a Syslog Agent in Windows Server 2012
document Installing and Configuring target iSCSI server on Windows Server 2012
document How To Make UEFI Bootable USB Flash Drive to Install Windows 8
document TCP/IP Command-line
document How to set up an Internet email account in Outlook 2013 or 2016
document Enable Hyper-V on Windows 8.1
document Quickly Turn ON/OFF Windows Firewall Using Command Line
document How to List All of the Windows and Software Updates Applied to a Computer
document How to Repair a Windows 7 System with an Installation Disc
document How to Create Bootable USB from a Windows ISO
document How to Create Bootable USB from an IMG File
document 20 Terminal shortcuts developers need to know
document How to Update Your BIOS
document Getting Started With Lync Mobile 2010 For Android Devices
document "Attachment size exceeds the allowable limit" error when you add a large attachment to an email message in Outlook
document How do I renew the IP address for my computer ?
document Is your Windows 10 PC slowing you down, and the SFC utility is unable to fix the problem? Then use DISM to repair the Windows image to enable SFC to do its job.
document How to make a full backup of a Windows 10 or Windows 8.1 PC
document How to create a System Restore Point in Windows 10 with a simple double-click
document How to properly remove the Windows.old folder on Windows 10
document How control your Windows 10 PC or phone with another computer with the Connect app
document How to use Bing images within Office and Edge on Windows 10 PC.
document How to fix taskbar search not working in Windows 10
document How to disable or uninstall OneDrive on Windows 10 PC
document How to re-activate Windows 10 after a hardware change
document How to change the system language across your whole Windows 10 PC
document Use Windows Defender Offline to remove tough viruses from your Windows 10 PC
document 16 Essential keyboard shortcuts everyone should know using Continuum for phones
document How to disable Action Center in Windows 10
document How to use Storage Spaces in Windows 10
document How to generate a Battery Report in Windows 10.
document HOW TO CONTROL YOUR PRIVACY IN CHROMEBOOKS VS. WINDOWS 10
document Create Fake File in Window PC in Any Size and Any Format
document INCREASE BATTERY LIFE OF LAPTOP EASILY
document How to perform an image backup in Windows 8.1 or 10
document Block Windows 10 Upgrade
document Chrome reset for adware issues
document Revert from Windows 10 back to previous operating system
document Windows 7 Guide to using Microsoft Security Essentials
document Force Dragon Naturally Speaking to load a particular user profile
document Texthelp Read and Write Gold Prediction returns strange results or receives double letters
document Connect Powershell to your Windows Azure subscription
document How to set up desktop background image rotation in Windows 8
document How to adjust your Laptops screen brightness in Windows 8/8.1
document Microsoft Security Essential Install, Windows 7
document Set the default Microsoft Word template back to a blank document
document Schedule Windows to shutdown or restart after a time limit
document 20 Windows 8 and 8.1 shortcuts
document Bypass Windows 8 and 8.1 login screen
document All the Ways You Can Still Get Windows 10 for Free
document The Complete Guide to Giving Better Family Tech Support
document How to Stop Skype from Running in the Background on Windows 10
document How to Upgrade to a Larger Hard Drive Without Reinstalling Windows
document How to Find and Remove Duplicate Files on Windows
document Scammers Are Using a Fake Version of AdwCleaner to Trick People
document How to Use OneDrive as Your Default Save Location on Windows 8.1
document How To Fix a Blue Screen of Death
document How To Fix Comdlg32.dll Not Found or Missing Errors
document How to Fix Fm20.dll Not Found or Missing Errors
document How to Fix Gdi32.dll Not Found or Missing Errors
document How To Fix Libxml2.dll Not Found or Missing Errors
document How to Fix Mfc42.dll Not Found or Missing Errors
document How to Fix Mfc90.dll Not Found or Missing Errors
document How To Fix Msvcp71.dll Not Found or Missing Errors
document How To Fix Msvcp80.dll Not Found or Missing Errors
document How To Fix Msvcr70.dll Not Found or Missing Errors
document How To Fix Msxml6.dll Errors
document How to Fix Ole32.dll Not Found or Missing Errors
document How To Fix Oleaut32.dll Not Found or Missing Errors
document How To Fix Shell32.dll Not Found or Missing Errors
document How To Fix Sqlite3.dll Not Found or Missing Errors
document How To Fix Ssleay32.dll Not Found or Missing Errors
document How To Fix STOP 0x00000005 Errors
document How To Fix STOP 0x0000007B Errors
document Keep the Windows 10 Taskbar Visible While Using the On-Screen Keyboard
document EdgeDeflector Forces Cortana to Use Your Default Web Browser
document How to Move the Clock to Right-Most Corner on the Taskbar in Windows 10
document Add Control Panel (Or Any Program) To Your Right-Click Menu With a Registry Tweak
document Six Keyboard Shortcuts Every Computer User Should Know
document How to Upgrade Your Computer's Login Screen
document How to Use Windows 8's New File History Backup (aka Time Machine for Windows)
document What Kind of Maintenance Do I Need to Do on My Windows PC?
document How to Do a Clean Install of Windows Without Losing Your Files, Settings, and Tweaks
document How to disable Microsoft Windows 10 keylogger (enabled by default)
document How to Use the Cortana Voice Assistant in Windows 10
document How to Map a Network Drive in Windows 10
document How to Sync Your iPhone with Windows 10
document How to turn Off Windows Update in Windows 10
document How to Change a NetBIOS Name
document How to turn off Windows Automatic Updates in Windows 8/8.1
document How To Disable Updates in Windows 7
document How to Run Disk Cleanup on a Windows 7 Computer
document How to Check If Windows 10 Is Activated or Not
document How to Check CPU Speed
document How to Create a Shortcut to Windows Update in Windows 10
document How to Enter the BIOS Setup Utility or Boot Menu with windows
document How to Install Drivers
document How to Check the Application Event Log for Errors
document How to Optimize Windows 10 Performance by tweaking Visual Effects
document How to Setting Password Protected Print Jobs
document How to Change User Account Name in Windows 10
document How to Set Up and Use Remote Desktop for Windows 10
document How to Find Drivers for Devices Using a Hardware ID
document How to Changing BIOS mode from UEFI to Legacy
document How to Speed Up Windows 10
document How to Outlook 2010 - Rebuild the index file
document How To Fix Outlook 2016 Search Problems
document How to Release and renew IP address
document How to HP Printers - USB Printer Setup (Windows)
document How to disable Windows Defender in Windows 7
document How to Turn On or Off Windows Defender in Windows 8 and 8.1
document How to Use Simple IF Statements in Excel
document Why Does 64-Bit Windows Need Two Program Files Folders?
document How to Assign a Static IP Address in Windows 7, 8, 10, XP, or Vista
document How to manually add a print server port?
document How to Join Your Computer to a Domain
document How to Force a Blue Screen in Windows
document How to Use All of Windows 10 Backup and Recovery Tools
document How To Repair HDD with DLC 2015
document How to change XAMPP apache server port?
document How to find computer serial number
document How to use Rufus to create a bootable USB drive to install (almost) any OS
document How do I format a USB Flash Drive to NTFS file system?
document Change RAID Type of a Volume or Disk Group
document Create an Admin User Account Using CMD Prompt (Windows)
document How to Find Your MAC Address in Windows 10
document How To Repair Windows 10
document Repair an Office application
document Add an email account to Outlook for PC
document How to install Office 365 on Windows PC
document How to test your home internet connection speed



RSS