Installing PHP on Your Laptop
March 29, 2016 Chris Ringer
In my introductory article I walked you through a crash course in PHP. Now I will show you how obtain a free PHP development environment on your laptop in two easy installations of XAMPP and Netbeans. This allows you the freedom to configure PHP and test your scripts as you choose without affecting a production website or needing management approval.
However, if you need to manage PHP scripts on an IBM i, you will want to alternatively explore using Zend Studio. This full-featured IDE integrates directly with the IBM i and allows you to write and debug scripts stored on the IFS. All developers of IBM i customers may download Zend Studio and register a free perpetual license for that version using an email address and the IBM i serial number. When you run your 30-day trial version of Zend Studio, just click on “Get a License for IBM i” instead of “Purchase Now” in the trial screen (Figure 1).
Setting A Good XAMPP Pull
First we will install the open source package XAMPP (“ex-amp”) that contains:
Choose your download preference here. I selected the Windows version of PHP 5.6.15 (I couldn’t get the debugger to work in version 7.02) and the download took two minutes. And do click on the “What’s Included” link on that web page to see what the other tools are included in the download.
Your download folder will then contain an executable file with a name similar to “xampp-win32-5.6.15-1-VC11-installer.exe.” Per the XAMPP documentation, disabling your anti-virus software will make the installation go faster. Double click this executable file to begin the installation.
You will be shown six screens.
Grinding Some Fine NetBeans
Let’s now install the NetBeans PHP IDE. This includes: PHP/HTML5/CSS Editor
Navigate to Netbeans and click on the orange download button. Select your IDE spoken language, platform, and depending on the CPU of your computer, either the x86 or x64 PHP bundle to start the download. I chose English, Windows, and x64. The download took 4 minutes.
To begin the installation, double click on the netbeans-8.1-php-windows-x64.exe file in your downloads folder. You will be shown five screens.
Configuration is Easy
If you look at newly installed programs in Control Panel and sort by date, you will see XAMPP and NetBeans. XAMPP also needs a Visual C++ package and may install that as well (Figure 3).
To launch the XAMPP control panel, double click the program C:xamppxampp-control.exe. (If ports 80 and 443 are already in use and unavailable, follow these instructions.) For the Apache module, click Start under Actions to run the Apache server. Then click Config then PHP (Figure 4). This opens the php.ini in Notepad. This file contains system values for PHP.
Scroll to the bottom to the [XDebug] section and add these seven lines, save the changes and close NotePad.
[XDebug] zend_extension = "C:xamppphpextphp_xdebug.dll" xdebug.remote_enable=1 xdebug.remote_host = "127.0.0.1" xdebug.remote_port=9000 xdebug.remote_handler = "dbgp" xdebug.profiler_enable = 1 xdebug.profiler_output_dir = "C:xampptmp"
For convenience, set Apache to automatically start when the XAMPP control panel opens. Click on Config in the upper right corner and then check Autostart Apache (Figure 5). Save the changes and leave XAMPP running.
To launch the NetBeans IDE, double click the program C:Program FilesNetBeans 8.1binnetbeans.exe. We need to verify the XDebug debugger settings match the php.ini settings. Click on Tools -> Options -> PHP -> Debugging (Figure 6). The Debugger Port needs to match the php.ini XDebug value. If the default port value 9000 is already in use on your computer, change this value both here and in php.ini. Click OK to close the Options window.
Your First NetBeans Project
We will now create a new NetBeans project. A project can be thought of as a website directory that contains an index.php script plus your other scripts. You will see three screens.
And now create a test script named phpinfo.php.
Type this code below the <?php tag and save.
define('BR', '<br />') ; echo 'Running: ', __FILE__, BR ; echo 'System Name: ', php_uname('n'), BR ; // RTVNETA SYSNAME phpinfo() ;
This little script just echoes the full name of the script, the name of your computer and displays all the php.ini settings plus the PHP run-time values. In the menu, click Run then Run File and the output should display in your browser.
To debug this script, in the menu click Debug then Debug File. Click the orange down arrow repeatedly to step through the script line by line (Figure 8). To end the debug session, click the red square.
Hopefully that worked flawlessly for you. If you feel adventurous, copy the two scripts genDocName.php and testGenDocName.php from my previous article into this project and run those.
Chris Ringer has been coding in RPG since 1989, focusing primarily on order fulfillment, pharmaceutical and manufacturing environments. In his spare time he enjoys running and doing triathlons. “I’m not fast, usually placing in the middle of the pack, but we’re just as competitive back there.”