1. Introduction
Setting Up Linux,Windows and Mac OS,LAMP/WAMP/MAMP Server
Setting Up Linux,Windows and Mac OS, Apache/MySQL/PHP, To expand PHP webapps, you need to setup Apache, MySQL and PHP, in a so called LAMP (Linux/Apache/MySQL/PHP), WAMP (Windows/Apache/MySQL/PHP), or MAMP (Mac OS/Apache/MySQL/PHP) surroundings, for your operating platform.
There are methods of putting in LAMP/WAMP/MAMP:
- Install individual software components, i.E., Apache, MySQL and PHP.
- Install a package deal package, which incorporates all software components wished for growing PHP webapps.
For novices walking on Windows/Mac OS, I actually recommend the package deal method for simplicity (even though they may not bundled the modern-day releases). These are the bundles available:
- XAMPP @ https://www.Apachefriends.Org/index.Html (Cross-platform for Windows, Mac OS and Linux).
- WampServer @ http://www.Wampserver.Com/en/ (for Windows handiest).
- Zend Server (@ http://files.Zend.Com/assist/Zend-Server-Community-Edition/zend-server-community-edition.Htm) (Cross-platform for Windows, Mac OS and Linux).
- Easy PHP (@ http://www.Easyphp.Org/).
- Others.
I shall describe how to installation and setup a number of these bundles in Section “LAMP/WAMP/MAMP Servers”.
Integrated Development Environment (IDE) with Debugger
You additionally need to put in an IDE, such as Eclipse PHP Development Tool (PDT).
You need to setup those debugging tools and be acquainted with:
- Server-facet PHP debugging with xDebug (or Zend Debugger), and
- Client-side JavaScript debugging with Firebug.
Programming Languages
I shall expect that you have some simple information on those programming languages.
Otherwise, examine the relevant sections.
- Database programming: SQL (or PostgreSQL).
- Sever-aspect programming: PHP (or Python, or Perl).
- Client-facet programming: HTML, CSS and JavaScript. In addition, BootStrap and jQuery for superior programming.
Version Control System
Set up a Version Control System, consisting of Git, for backup, model manage and collaboration.
2. Setting Up Linux,Windows and Mac OS, LAMP/WAMP/MAMP Server
In this section, I shall in short describe how to deploy and customize a number of the AMP bundles.
To deploy man or woman additives.
2.1 XAMPP (For Windows/Mac OS/Linux)
The XAMPP (stands for Cross-platform, Apache, MySQL, PHP and Perl @ https://www.Apachefriends.Org/index.Html) bundles Apache, MySQL, PHP and Perl, for Windows, Linux and Mac OS.
It additionally includes FileZilla FTP Server, Mercury Mail Server, and Tomcat Server; plus gear PhpMyAdmin, Webalizer, and Fake Sendmail.
At the time of writing, XAMPP 1.8.Three bundles PHP five.Five.15, Apache 2.4.10, MySQL 5.6.20 and PhpMyAdmin four.2.7.1.
Installing XAMPP on Windows
- Download: Goto XAMPP mom site at https://www.Apachefriends.Org/index.Html ⇒ Download the Windows package (e.G., xampp-win32-1.Eight.Three-5-VC11-installer.Exe).
- Install: Simply run the downloaded Installer. Choose your set up directory. I shall expect that XAMPP is installed in “d:xampp”, denoted as , in this newsletter.
Installing XAMPP on Mac OS [@@To Check!!]
Download: Goto XAMPP mom web site at https://www.Apachefriends.Org/index.Html ⇒ Download the Mac OS package deal (e.G., …..). Install: Simply run the downloaded Installer. Choose your installation listing. I shall anticipate that XAMPP is hooked up in “……”, denoted as , in this article.
Starting/Stopping XAMPP Servers
Launch the “XAMPP Control Panel” (“xampp-manage.Exe” for Windows, @@To Check …… MAC OS) under the XAMPP set up directory.
A little icon appears in the Icon Tray. Right-click on on the icon ⇒ “Show/Hide” to show the “full” Control Panel Window.
The XAMPP Control Panel lets in you to begin/prevent every of those servers:
Apache HTTP Server, MySQL Database Server, FileZilla FTP Server, Mercury Mail Server, and Tomcat HTTP Server.
You also can test their configurations (“Config”), logs (“Logs”) and release the administrator gear together with PhpMyAdmin for MySQL (“Admin”).
Verifying the Apache/MySQL/PHP/Perl Installation
By default, a directory known as “htdocs” changed into created below the XAMPP installed listing, which serves because the Apache’s file root directory.
To verify the set up, launch the XAMPP Control Panel. Start the Apache and MySQL servers via clicking the “Start” buttons.
- On your browser, difficulty “http://localhost” to get the welcome page. Select your language, which leads you to the XAMPP home web page (below “htdocs/xampp”). You can now affirm all the components through clicking on the info hyperlinks at the left panel, e.G., phpinfo() for PHP, perlinfo() for Perl, PhpMyAdmin for MySQL.
- On your browser, difficulty “http://localhost/phpmyadmin” to get right of entry to the MySQL through PhpMyAdmin. Select the “Users” tab. Which reveals that no password is set for the superuser root and the anonymous consumer. (You can also click on the “Admin” button below MySQL to launch PhpMyAdmin.)
To shutdown XAMPP, forestall all of the offerings and press “Quit”.
Write a Hello-world PHP Script
By default, the Apache’s document root directory is placed at “/htdocs”.
Use a programming editor (which includes notepad++ for Windows, or gedit for Ubuntu/Mac OS) to jot down a simple PHP script called “whats up.Php” and save below the “htdocs” listing, as follows:
To run this PHP script, start a browser and issue URL http://localhost/hey.Hypertext Preprocessor, assuming that Apache server has been commenced.
Another Example: Write any other PHP script known as “phpinfo.Php” (saved below “htdocs”) to display the PHP settings underneath Apache, as follows:
Run the script by issuing URL “http://localhost/phpinfo.Personal home page”.
XAMPP Directory Structure
XAMPP is prepared in the sub-directories. The crucial ones are:
- htdocs: the default apache’s record root listing.
- Apache, mysql, FileZillaFTP, MercuryMail, tomcat: for the server software program.
- PhpMyAdmin: for the PhpMyAdmin tool.
- Hypertext Preprocessor, perl: for the languages.
Apache Configuration
The Apache’s major configuration record “httpd.Conf” is placed at “apacheconf”.
Take note of the subsequent configuration directives:
- The core directives are:
ServerRoot “/apache” Listen 80 ServerName localhost:80 DocumentRoot “/htdocs”
The ServerRoot specifies the apache’s installed directory.
Listen specifies the TCP port number for Apache internet server, in this situation, default of TCP port eighty.
The DocumentRoot specifies the foundation listing of the net server.
The directives related to listing authorization are:
# # Deny access to the entirety of your server’s file system. You must # explicitly permit access to web content directories in other # blocks below. # AllowOverride none Require all denied # # DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, but # symbolic links and aliases may be used to point to other locations. # DocumentRoot “/htdocs” <Directory “/htdocs”> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All # # Controls who can get stuff from this server. # Require all granted
[TODO] Explanation
- The directives related to logging are:
ErrorLog “logs/error.log” CustomLog “logs/access.log” combined
PHP Configuration
The PHP’s main configuration file “php.ini” is located from “<XAMPP_HOME>\php” (as revealed by phpinfo( ) output).
[TODO] Explanation
MySQL Configuration
The MySQL’s main configuration file “my.ini” is located at “<XAMPP_HOME>\mysql\bin
“.
Take note of the following settings:
- MySQL Server Daemon (
mysqld.exe
)
[mysqld] port = 3306 socket = “/mysql/mysql.sock” basedir = “/mysql” tmpdir = “/tmp” datadir = “/mysql/data” pid_file = “mysql.pid” log_error = “mysql_error.log”
The port specifies the TCP port quantity for the MySQL server (defaulted to 3306).
The basedir specifies the MySQL mounted directory. The datadir specifies the databases listing.
The log-errors specifies the MySQL mistakes log report.
- MySQL Interactive Client (
mysql
)
[client] port = 3306 socket = “/mysql/mysql.sock”
Customizing MySQL
The default MySQL installation creates a superuser called “root” without password. It additionally affords an anonymous user with out a password. You need to
- Set a password for “root”.
- Remove the nameless person.
- You ought to now not use superuser “root” for everyday day by day operations. Instead, create a new consumer (says xampppuser) for operational use.
There are a few ways to administer MySQL, through the graphical patron “PhpMyAdmin”, or command-line patron “mysql”.
- PhpMyAdmin: login to PhpMyAdmin via “http://localhost/phpmyadmin”. Click the “Users” tab ⇒ Set password for root (for all hosts) (Select ⇒ Edit Privilege ⇒ Change Password ⇒ GO ⇒ Refresh). Delete the nameless user denoted as “Any” User (Select ⇒ Remove selected customers ⇒ GO). Create a new user known as “xampppuser” through clicking the “Add User”. Grant all privileges to start with.
- Note: Once you put a password for root, you can need to adjust the PHP configuration document a good way to login with the brand new password. See “PhpMyAdmin PHP Configuration”.
- MySQL command-line patron (“mysql.Exe”)
Start a new PHP Webapp
To begin a brand new PHP webapp, create you running listing underneath “htdocs” (says directory “hi there”).
You can release your webapp through URL “http://localhost/good day”.
Alternatively, you could use the “htdocs” directory, through getting rid of all the prevailing contents.
You can get right of entry to the webapp via URL “http://localhost”.
For Production, configure a virtual host (in Apache) to your project.
2.2 WampServer 2.5 (For Windows)
WampServer (@ http://www.Wampserver.Com/en/) bundles Apache, MySQL and PHP for Winodws in a single package deal.
It also includes gear inclusive of PhpMyAdmin (a MySQL database management device), S-B (an alternative to PhpMyAdmin), XDebug (a PHP Debugging Tool), WebGrind (a PHP Profiling Tool).
At the time of writing, WampServer 2.5 bundles Apache 2.Four.Nine, MySQL 5.6.17, PHP 5.5.12, PhpMyAdmin four.1.14, SqlBuddy 1.3.Three and XDbebug 2.2.Five.
Installing WampServer
To Install WampServer:
- Download: Goto WampServer mother website at http://www.Wampserver.Com/en ⇒ Select “DOWNLOADS” ⇒ Choose the appropriate package deal to your platform (32-bit or sixty four-bit) ⇒ Download the set up document (e.G., wampserver2.Five-Apache-2.4.Nine-Mysql-5.6.17-php5.5.12-64b.Exe).
- Install: To installation the WampServer, in reality run the downloaded installation record. Choose your installation listing. I shall assume that WampServer is mounted in “d:WampServer”, denoted as , in this article.
Starting/Stopping WampServer
To start the WampServer, choose “Start WampServer” from the “Start” menu; or run “wampmanager.Exe” from the WampServer hooked up directory.
An little icon will seem at the icon tray. “Green” shows that every one the services have started; at the same time as “Red” suggests that each one the offerings have stopped. Click on the icon to open the “WampServer Control Panel”. You ought to:
- Under “Quick Admin”: Start/Stop/Restart all of the services (Apache & MySQL services).
- Put the server on-line (in order that user can get right of entry to the server over the Internet) or offline.
- Configure Apache, MySQL and PHP, under their respective sections.
- Launch “PhpMyAdmin”.
- Others.
To shutdown the program, click “Stop All Services” on WampServer Control Panel ⇒ right-click on at the WampServer icon ⇒ Exit.
Verifying Apache/MySQL/PHP Installation
By default, a directory known as “www” changed into created beneath the WampServer hooked up directory, which serves because the Apache’s document root listing.
A welcome web page known as “index.Hypertext Preprocessor” turned into also created within the “www” directory.
To verify the set up:
- Start the WampServer. Wait for the icon to show green indicating all offerings have commenced (otherwise, click the icon and select “Start All Services”).
- For checking out, put the server “offline” to disable outside get right of entry to (i.E., it can most effective be accessed in localhost).
- To verify Apache: Start a browser and trouble URL http://localhost. This will in flip request for “index.Hypertext Preprocessor”. The index web page provides links to documentations, aliases and tools.
- The installation creates these aliases for Apache: phpmyadmin, sqlbuddy, phpsysinfo for the respective offerings. You can issue URL http://localhost/alias-name to get admission to these offerings.
- To verify MySQL: Issue URL http://localhost/phpmyadmin to get right of entry to the MySQL via PhpMyAdmin.
- Click on the “Users”, which exhibits that no password was set for the superuser root and the anonymous person.
- To verify PHP: Issue URL http://localhost/?Phpinfo=1, which runs the phpinfo() feature.
Write a Hello-world PHP Script
Use a programming editor (such as notepad++ for Windows, or gedit for Ubuntu/Mac OS) to write a simple PHP script called “hello.php
” and save under the “www
” directory, as follows:
<html>
<head>
<title>First PHP Page</title>
</head>
<body>
<?php
echo '<h1>Hello, world!</h1>';
?>
</body>
</html>
To run this script, start a browser and issue URL http://localhost/hello.php
, assuming that the Apache server has been started.
Another Example: Write another PHP script called “phpinfo.php
” (saved under “www
“) to display the PHP settings under Apache, as follows:
<?php
phpinfo();
?>
Run the script by issuing URL “http://localhost/phpinfo.php
“.
WampServer Directory Structure
WampServer is organized within the following directory shape. The crucial ones are:
bin: includes binaries for Apache, MySQL, and PHP, in their respectively sub-directory. For every aspect, you may installation multiple versions and pick out one in all them in operation. Apps: includes server-facet tools including PhpMyAdmin, SQL-Buddy, and WebGrind. Equipment: includes client-side tool inclusive of xdc (XDebug Client). www: the default apache’s file root listing. Logs: includes apache, Hypertext Preprocessor, mysql error/access logs. Alias: carries the the apache’s alias configuration for PhpMyadmin, SQL-Buddy and WebGrind.
Apache Configuration
The Apache’s essential configuration document “httpd.Conf” is placed at “binapacheApache2.X.Xxconf”. Take word of the subsequent configuration directives.
- The center directives are:
ServerRoot "<WAMPSERVER_HOME>/bin/apache/apache2.x.xx"
Listen 80
ServerName localhost:80
DocumentRoot "<WAMPSERVER_HOME>/www/"
The ServerRoot specifies the apache’s set up listing. Listen specifies the TCP port range for Apache internet server, in this situation, default of TCP port 80.
The DocumentRoot specifies the foundation directory of the net server.
- The directives related to directory authorization are:
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its sub-directories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
#
# This should be changed to whatever you set DocumentRoot to.
#
DocumentRoot "<WAMPSERVER_HOME>/www/"
<Directory "<WAMPSERVER_HOME>/www/">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
[TODO] Explanation
- The directives related to logging are:
ErrorLog "<WAMPSERVER_HOME>/logs/apache_error.log"
CustomLog "<WAMPSERVER_HOME>/logs/access.log" common
PHP Configuration
The PHP’s primary configuration for Apache2 “personal home page.Ini” is located at “binapacheApache2.X.Xxbin” (as discovered by way of phpinfo() output).
[TODO] Explanation
MySQL Configuration
The MySQL’s fundamental configuration record “my.Ini” is located at “binmysqlmysql5.X.Xx”.
Take note of the subsequent settings:
- MySQL Server
[wampmysqld]
port = 3306
socket = /tmp/mysql.sock
basedir=<WAMPSERVER_HOME>/bin/mysql/mysql5.x.xx
log-error=<WAMPSERVER_HOME>/logs/mysql.log
datadir=<WAMPSERVER_HOME>/bin/mysql/mysql5.x.xx/data
The port specifies the TCP port number for the MySQL server (defaulted to 3306). The basedir specifies the MySQL mounted listing.
The datadir specifies the databases directory. The log-errors specifies the MySQL error log report.
MySQL Server Daemon (mysqld.Exe)
[mysqld]
port = 3306
MySQL Interactive Client (mysql)
[client]
port = 3306
Customizing MySQL
Setting Up Linux,Windows and Mac OS,The default MySQL set up creates a superuser “root” with out password. It additionally creates an nameless user with no password. You want to:
- Set a password for “root”.
- Remove the anonymous consumer.
- You should no longer use superuser “root” for ordinary each day operations. Instead, create a new person (says wampuser) for operational use.
There are many ways to manage MySQL, through the graphical consumer “PhpMyAdmin” or “S-B”; or command-line customer “mysql.Exe”.
- PhpMyAdmin: login to PhpMyAdmin via “http://localhost/phpmyadmin”. Click the “Users” tab ⇒ Set password for root (for all hosts) (Select ⇒ Edit Privilege ⇒ Change Password ⇒ GO ⇒ Refresh). Delete the nameless consumer denoted as “Any” User (Select ⇒ Remove decided on users ⇒ GO). Create a new person referred to as “wampuser” with the aid of clicking the “Add User”. Grant all privileges to start with.
- Note: Once you place a password for root, you can need to modify the PHP configuration record in order to login with the new password. See “PhpMyAdmin PHP Configuration”.
- SQL Buddy: login to SQL through “http://localhost/sqlBuddy”. Click “Submit” with empty password for “root”. Select “Users”. Set password for all root customers of all hosts (Select ⇒ Edit). Remove the anonymous user (the row with empty consumer call) (Select ⇒ Delete). Create a new person known as “wampuser” by way of filling in “Add a New User”. Grant all privileges besides the “Grant choice” first of all.
- MySQL command-line customer (“mysql.Exe”)
Start a new PHP Webapp
To start a brand new PHP webapp, create you working listing under “www” (says directory “hey”). You can release your webapp via URL “http://localhost/good day”.
Alternatively, you could use the “www” listing, via getting rid of all the present contents. You can get admission to the webapp thru URL “http://localhost”.
For Production, configure a virtual host (in Apache) on your project
2.3 LAMP Server (For Ubuntu)
3. Setting Up Linux,Windows and Mac OS, Eclipse PDT (PHP Developer Tool)
Eclipse PDT (@ http://www.Eclipse.Org/pdt) is an IDE for PHP webapp improvement.
The fundamental advantage is it can debug PHP server-aspect scripts with XDebug or Zend Debugger extension.
Alternative PHP IDEs are: NetBeans (@ http://www.Netbeans.Org), PHPEclipse (@ http://www.Phpeclipse.Com).
Install Eclipse PDT
If you have by no means installed any Eclipse bundle, goto Eclipse mother website online @ http://www.Eclipse.Org ⇒ Downloads ⇒ Select “Eclipse for PHP Developers”:
- For Windows: Download the ZIP record (32-bit or sixty four-bit). Unzip the downloaded record in a listing of your desire.
- For Mac OS:
- For Ubuntu:
If you have established an Eclipse package deal (consisting of Eclipse IDE for Java Developers), you can add the PDT plugin by way of:
- Launched Eclipse ⇒ Select “Help” menu ⇒ “Install New Software”.
- The “Install” dialog seems. In “Work with” area, pull down the drop-down menu and choose “Neon – http://down load.Eclipse.Org/releases/neon” for Eclipse four.6 (or “Mars” for Eclipse four.5; or “Luna” for 4.4; or Kepler for 4.3; Juno for 4.2; helios for Eclipse 3.7).
- In the “Name” field, expand “Programming Language” node ⇒ Check “PHP Development Tools (PDT)” ⇒ Next ⇒ Accept the license ⇒ Finish.
Configure Eclipse PDT with XDebug
Assume which you have install xDebug (that’s bundled with XAMPP and WampServer).
Launch Eclipse ⇒ Select “Window” menu ⇒ Preferences ⇒ Expand the “PHP” node:
Select “Servers” ⇒ Check that there may be an entry with “Name” of “Default PHP Server” and “URL” of “http://localhost” ⇒ Select the entry ⇒ Edit ⇒ Select “Debugger” tab ⇒ In “Debugger”: Select “XDebug”.
Select “PHP Executable” ⇒ “Add”:
- In “Name”, Enter a call, e.G. “myPHP”, “WampServer” or “XAMPP”.
- In “Executable Path”, input the area of PHP executable “php.Exe” (e.G., “binphpphp5.X.Xphp.Exe” for WampServer, “phpphp.Exe” for XAMPP (Windows)).
- In “PHP ini report”, input the personal home page configuration file utilized by the Apache (e.G., “binapacheApache2.2.Xxbinphp.Ini” for WampServer. “phpphp.Ini” for XAMPP (Windows)).
- In “PHP Debugger”, select “XDebug” (which is bundled in WampServer and XAMPP).
Select “Debug”:
- In “Server”, choose “Default PHP Server”.
- In “PHP Executable”, select the PHP Executable configured inside the previous step (i.E., “WampServer” or “XAMPP”).
Select “Manual” ⇒ Check that there may be an access with “Site Name” of “personal home page.Net” with “URL” of “http://www.Php.Internet/guide/en”.
Browse thru the alternative settings for PHP.
Writing a Hello-world PHP program in Eclipse PDT
Setting Up Linux,Windows and Mac OS,Launch Eclipse. Choose a workspace.
Create a new PHP project: “File” ⇒ New ⇒ PHP Project (or “Project…” ⇒ PHP ⇒ PHP Project).
- In “Project Name”, input a name for the undertaking, e.G., “howdy”.
- In “Contents”, pick out “Create assignment at exiting place”, input your web server’s root listing observed with the aid of the task call (e.G., “wwwhello” for WampServer, “htdocshello” for XAMPP – Make a sub-directory referred to as “howdy” underneath “www” or “htdocs”) ⇒ “Finish”.
Write your PHP program: Right-click on at the assignment “howdy” ⇒ “New” ⇒ “PHP File”.
Enter the following codes and stored as “HelloObj.Hypertext Preprocessor”:
<?php
class Hello{
// Variables
var $message;
// Constructor
function __construct(){
$this->message= "Hello World!";
}
/**
* Function that prints the value of the instance variable $message
*/
function printMessage(){
echo $this->message;
}
}
?>
Again, create a new PHP file for the following driver program “HelloDriver.php
“:
<?php
include_once('HelloObj.php');
$hello= new hello();
$hello->printMessage();
?>
To run this system, right-click on anywhere on “HelloDriver.Php” ⇒ “Run As” ⇒ “PHP Web Application” (output shown in Eclipse internal browser or external browser) ⇒ The launch URL shall be http://localhost/howdy/HelloDriver.Hypertext Preprocessor.
To pick out your browser, pick “Window” ⇒ Preferences ⇒ General ⇒ Web Browser ⇒ Choose your browser, including inner internet browser, or external web browser (Firefox, IE, and many others). The browser shall show “Hello World!”.
Note: You can also run this script as a “PHP CLI Application”, i.E., a standalone command-line interface program instead of server-side script, because the above application are in basic terms PHP, and not using a HTML statements.
Debugging PHP Server-side Script
4. Setting Up Linux,Windows and Mac OS, PhpMyAdmin
PhpMyAdmin (http://www.phpmyadmin.net) is a popular open source web-base tool intended to handle the administration of MySQL database system.
Installing PhpMyAdmin
PhpMyAdmin is bundled in WampServer, installed under “<WAMPSERVER_HOME>\apps\phpmyadmin4.x.xx
“. It is also bundled in XAMPP, under “<XAMPP_HOME>\phpmyadmin
“.
Launching PhpMyAdmin
PhpMyAdmin is an Apache PHP application. Typically, an alias called “phpmyadmin
” is defined which maps to its installed directory.
To launch PhpMyAdmin, start Apache and MySQL servers. Then, start a browser and issue URL http://localhost/phpmyadmin
.
Using PhpMyAdmin
[TODO]
PhpMyAdmin’s Configuration for Apache
- In WampServer: PhpMyAdmin is configured in “aliasphpmyadmin.Conf”, that is blanketed into Apache’s main configuration record “binapacheapache2.4.9confhttpd.Conf” via directive “Include “/alias/*””. The “phpmyadmin.Conf”, an alias called “/phpmyadmin” is described which maps to PhpMyAdmin’s listing “/apps/phpmyadmin4.X.Xx/”.
- In XAMPP: PhpMyAdmin is configured in “apacheconfextrahttpd-xampp.Conf”, that’s included into Apache’s major configuration file “apacheconfhttpd.Conf” via an Include directive. The configuration, an alias referred to as “/phpmyadmin” is defined which maps to PhpMyAdmin’s directory at “/phpMyAdmin/”.
PhpMyAdmin’s PHP Configuration
PhpMyAdmin is a PHP app walking under Apache. The PHP app makes use of a configuration file called “config.Inc.Personal home page”, placed on the PhpMyAdmin mounted listing.
The default configuration uses so-referred to as “config” authentication kind which calls for you to hardcode the MySQL person and password in the configuration file:
$cfg['Servers'][$i]['auth_type'] = 'config'
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'your_root_password';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
If you change MySQL root’s password, you need to enter the new password into this file, in order to login into MySQL.
I recommend that you change the authentication type to “cookie”, which prompts you to for the login user and password.
// $cfg['Servers'][$i]['auth_type'] = 'config'
$cfg['Servers'][$i]['auth_type'] = 'cookie';
// $cfg['Servers'][$i]['user'] = 'root';
// $cfg['Servers'][$i]['password'] = 'your_root_password';
// $cfg['Servers'][$i]['AllowNoPassword'] = true;
Notes on Errors
- Cannot login using
root
, after setting password. See above. - If you get an error “Connection for controluser as defined in your configuration failed”, see “http://stackoverflow.com/questions/11506224/connection-for-controluser-as-defined-in-your-configuration-failed-phpmyadmin-xa”. (I encountered this error for XAMPP.)
5. SQL Buddy
Setting Up Linux,Windows and Mac OS, SQL Buddy (http://www.sqlbuddy.com) is an alternative to PhpMyAdmin. SQL-Buddy is bundled in WampServer, under directory <WAMPSERVER_HOME>\apps\sqlbuddy1.3.x
. SQL-Buddy could be easier to use than PhpMyAdmin.
To use SQL-Buddy, start a browser, and issue URL http://localhost/sqlbuddy
.
[TODO] more user guide
6. Debugging PHP Webapps
6.1 XDebug for Debugging Server-side PHP Script
XDebug (@ http://xdebug.Org) is an PHP extension, that allow you to debug server-side PHP Script walking beneath Apache in Eclipse PDT.
Install xDebug Extension for PHP
- For WampServer, xDebug module is set up as “/bin/php/php5.X.Xx/zend_ext/php_xdebug-2.X.X-five.X-vc11-x86_64.Dll”.
- XAMPP (Windows), xDebug module is “/php/ext/php_xdebug.Dll”.
- For XAMPP (Mac OS), xDebug module is …… @@To check
- For Ubuntu, study “Install XDebug extension for PHP” for Eclipse PDT”.
- To verify that xDebug is installed, seek the phpinfo() output (run “phpinfo.Hypertext Preprocessor” written earlier) for “xdebug”, which shall show up as follows:
Configure xDebug for Eclipse PDT
Find the PHP configuration document for Apache from the phpinfo() output, under “Loaded Configuration File”.
- For WampServer, it is “binapacheapache2.4.9binphp.Ini”.
- For XAMPP (Windows), it’s far “/php/Hypertext Preprocessor.Ini”.
- XAMPP (Mac OS), it’s far “/Hypertext Preprocessor/php.Ini”. (@@ To Check)
- For Ubuntu: See “Install XDebug extension for PHP” for Eclipse PDT”.
Check if the following strains are included within the PHP configuration document (encompass them in any other case):
; For WampServer
zend_extension = "<WAMPSERVER_HOME>/bin/php/php5.5.12/zend_ext/php_xdebug-2.2.5-5.5-vc11-x86_64.dll"
; For Ubuntu
zend_extension=xdebug.so
; For XAMPP (For Windows)
zend_extension = "<XAMPP_HOME>/php/ext/php_xdebug.dll"
; For XAMPP (for Mac OS)
zend_extension = "<XAMPP_HOME>/......."
......
[xdebug]
xdebug.remote_enable = On
xdebug.remote_port = 9000
xdebug.remote_host = 127.0.0.1
Restart the Apache Server.
Example 1: Debugging PHP Server-side Script
Setting Up Linux,Windows and Mac OS, Let’s trace through the “hi there” PHP Webapp created in advance, which contains PHP scripts: “HelloDriver.Php” and “HelloObj.Personal home page”.
- Set a breakpoint at line 2 of “HelloDriver.Personal home page” by way of clicking at the left margin.
- Right-click on “HelloDriver.Personal home page” ⇒ “Debug As” ⇒ “PHP Web Application”.
- Switch to “Debug” perspective.
- The application shall damage at line 2 of “HelloDriver.Personal home page”. Click “Step Into (F5)” or “Step Over (F6)” to trace via the program. Inspect the variables and observe the output at the internet browser.
- You need to terminate the debugging consultation with the aid of pushing the “Terminate” button.
Take word that if you check “Break at First Line” within the debug configuration, the program will pause at the first line of a PHP file. You need to push “Resume” or “Step Over”.
Example 2: Debugging PHP Webapp (HTML+PHP)
Setting Up Linux,Windows and Mac OS,Create the following two files “Query.php
” and “ProcessQuery.php
“, saved under Apache’s document root directory.
<!DOCTYPE html>
<!-- Query.php -->
<html>
<head>
<title>Test HTML Form</title>
</head>
<body>
<form method="post" action="ProcessQuery.php">
What is your name? <input type="text" name="username" />
<input type="submit" />
</form>
</body>
</html>
<?php
// ProcessQuery.php
echo '<h2>Thank you for your query</h2>';
if (isset($_POST['username'])) {
echo '<h2>Hello, ' . htmlentities($_POST['username']) . '</h2>';
}
?>
Note: This code is meant for illustrating PHP webapp debugging. In exercise, the two documents are regularly merged into one.
To run the PHP webapp, right-click on “Query.Php” ⇒ Run As ⇒ PHP Web Application
To debug the PHP webapp:
- proper-click on “Query.Html” ⇒ Debug As ⇒ Debug Configuration ⇒ Select “Debugger” tab ⇒ Check “Break at First Line” (which units a breakpoint at the start of each file) ⇒ “Debug”.
- Switch to “Debug” attitude.
- Push “Resume (F8)” button to run thru the HTML code.
- Switch to the browser. Enter some thing within the textfield and click on “submit”.
- Switch again to Eclipse, it now breaks at the first line of “ProcessQuery.Php”.
- Click “Step Into (F5)” or “Step Over (F6)” to hint via this system. Inspect the variables and take a look at the output at the internet browser.
- You need to terminate the debugging session with the aid of pushing the “Terminate” button.
Take word that if your application includes HTML and PHP, your need to exchange among the internet browser (to enter data) and eclipse (to push “Resume” to run via the HTML codes, or “Step Over/Into” to execute the PHP codes).
At times, the browser/eclipse icons at the taskbar breaking point to remind you to replace over.
Note: I absolutely intend to call “Query.Personal home page” and “Query.Html”, but the XDebug session does now not seem to begin on HTML (even though you can tailor the “Run configuration” to start strolling from an HTML file)?!
Let me realize if you have a solution. For the time being, name all documents (can be most effective the beginning web page) “.
Hypertext Preprocessor” even they contains only HTML. This is not really a trouble.