Create (or) Configure PHP developement environment locally


            Developing a PHP based application is easy. All you need is the latest PHP files and a text editor. To download the PHP files you can go to the following link; http://windows.php.net/download#php-7.0

            You can skip the debug file for now, although it is always good to have it on your system. After downloading the files and extracting them to the location of your choice, you should follow these steps to get started. Before starting you should know that installing PHP is easy but it requires a server to run. PHP is best run on an Apache Tomcat server. A server is a host for a backend script to run. Apache can be downloaded from the following link https://tomcat.apache.org/download-80.cgi

           You can always download the entire package with PHP, Apache, MySQL for windows. These packages help in developing web based applications. They are available on the internet as WAMP stack. You can download these stacks and install them. The underlying tutorial for manual installation. I am assuming you have extracted the PHP files to the C drive of your PC, and have the Apache server installed. If not here is the link http://www.sitepoint.com/how-to-install-apache-on-windows/ 

Step 1 - Configure php.ini file 
         Copy C\php\php.ini-recommended to C\php\php.ini. There are several lines you will need to change in a text editor.
Define the extension directory-
extension_dir = "C:phpext"

Enable different extensions. For now we will enable following extensions but it depends on the functionality that you want.
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_pdo.dll
extension=php_pdo_mysql.dll
extension=php_xmlrpc.dll

If you want to send mails in the future using mail() function
[mail function]
; For Win32 only.
SMTP = mail.myisp.com
smtp_port = 25
; For Win32 only.
sendmail_from = my@emailaddress.com

Step 2 - add C:php to the path environment variable
         To ensure Windows can find PHP, you need to change the path environment variable. From the Control Panel, choose System, (then “Advanced system settings” in Vista), select the “Advanced” tab, and click the “Environment Variables” button.
Scroll down the System variables list and click on “Path” followed by the “Edit” button. Enter “;C:php” to the end of the Variable value line (remember the semi-colon).  

You might need to reboot at this stage.

Step 3 – Configure PHP as an Apache module
        Ensure that Apache is not running. Open its configuration file confhttpd.conf . Change the following lines.
Line 239, add index.php as the default file name.
DirectoryIndex index.php index.html

At the bottom of the file add the following lines.
# PHP5 module
LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php"
Save the configuration file and test it from the command line (Start->run->cmd).
cd Apache2bin
httpd –t

Step 4 – Test a php file
        Create a file named index.php in Apache’s web page root (either htdocs or D:WebPages) and add this code
<?php phpinfo(); ?>

         Ensure Apache has started successfully, open a web browser and enter the address http://localhost/. If all goes well, a “PHP version” page should appear showing all the configuration settings.You can follow the above steps to develop PHP applications, but if you are a beginner you should start developing apps using an IDE. There are a number of IDEs used for developing PHP applications. 
          One of the best IDE is PHPStorm. It helps you with autocomplete and providing an array of functionality form its own side. The best part about the IDE is that it can be used to develop HTML, JavaScript, CSS and a lot of other web related files. Though it is not free, you can get a yearlong free subscription using your colleges email ID (myid@college_name.ac.in OR myid@college_name.edu ). There are a number of free IDEs available too.





Reactions:

0 comments :

Post a Comment