September 06 2010 04:01
Navigation
Forum Threads
Newest Threads
· Youtube Panels
· Share This V3.03 Rel...
· Do you use fusionboa...
· Enhanced Profile V1....
· Avatar maker
Hottest Threads
· Ajax Forum Post R... [137]
· Center News Panel... [59]
· We Have A Winner ... [53]
· Ajax Forum Panel ... [53]
Latest Articles
· Integrating jixedbar...
· Enabling TinyMCE Med...
· How To Run PHP-Fusio...
· PHP-Fusion Developer...
· How To Make Your Web...

Need an account? Sign Up for FREE PHP-Fusion MOD's, Themes & Support!
Please enter your details below.
Your user name and password is case-sensitive.




Enter Validation Code:



Remember Me

I agree with the TOA



Forgotten your password?
Request a new one here.


Not a member yet?
Click here to register.


Google Translate

How To Run PHP-Fusion Locally With A Debugger
Read how I set up my PC to run PHP Fusion locally with a debugger.

Follow the tips, and you will be able to increase productivity in relation to debugging your PHP code.

Introduction

Most users run php-fusion at a host over the internet, while they write their code locally. Before code can be tested it needs to be uploaded, usually by means of an FTP program.

Nothing is wrong with that, but if you would like to run and test your own php-fusion code locally in an environment that allows efficient debugging (debugging is the work with identifying and correcting errors in your code, and a debugger is a tool that facilitates that), you may want to consider the following.

Before being able to use a debugger, my main methods for debugging PHP scripts were to set up a bunch of echo statements that printed variable values or use "I am here" echo statements to print the position in the scripts. I'd then have to remove these lines of code or comment them out before deploying the script.

These techniques worked fine for me, but consume much more time than working with an application in a debugger:


In the debugger you can temporarily suspend execution at given points in the code, and inspect variables. Even $_GET and $_POST variables can be inspected


You can also step through your code line by line


If you need to correct your code, just type the changes, as a full blown editor is part of the debugger. No more save and upload to see the effect. Other things are also easier. For example you can open the file with a given function just by a click on the call to the function. Eclipse keeps track on where it is found


You?ll also have help readily available, as you can call up the PHP manual for a given function by a click


So, you can save a great deal of time using a debugger.

Getting started
If you're hooked read on.

This submission is not a step-by-step introduction. Nether is this submission a detailed introduction to using the debugger. It is rather an explanation of my experiences. There are several reasons for that. First, and most important I have only recently started experimenting with Eclipse. I'm surely unable to foresee the difficulties you may run into under varying conditions. Second, there are several builds of Eclipse available which in turn may be combined with various servers and databases.

While it is not a step-by-step introduction, I hope it encourages more people to experiment and contribute, for the purpose of guiding us in direction of appropriate and efficient development tools.

For the above reasons I assume some familiarity with the topics.

Installation
In order to accomplish our goal you will need:


  • ZEND: PHP
  • MySQL: Database
  • Phpmyadmin: Tool to administer the database
  • Eclipse: The debugger
  • Apache: Server


First, download Eclipse from http://www.zend.com/en/community/pdt (select the one that matches your OS? my experiences are solely based on Windows) and install it. It comes as a zip file, and apart from unpacking it, no further installation is needed. Unpack it to a directory path outside /programmes (I got difficulties with permissions, when I tried that).

Second, download ZEND from http://www.zend.com/en/downloads/ and install it. Remember not to select the version of ZEND containing PHP 5.3, as php-fusion is currently incompatible with PHP 5.3. During the installation, select Custom installation and include phpmyadmin and MySQL and later include Apache. If you already have these installed, or if you want to user another server, you may want to choose differently. Select a path outside /programmes (I got difficulties with permissions, when I tried that).

Testing the environment
Test that the server is running. Identify the directory where 'web-documents' reside. If you followed my recommendation, it's probably something like 'My documents/workspace/zend/Apache2/htdocs'.

Create a file called stest.php:

Code:
<?php
echo("Hello world...");
?>

at save it in that directory. Open your browser at type the following url:

localhost/stest.php


If it outputs "Hello world...", you have succeeded. If it cannot recognize your page, it may be because you are not using the default port, which is port 80 (you may not be able to do so, if you?re using Skype). It that case try the following url:

Localhost:81/stest.php

Where 81 is the port number you selected.

If that doesn't work neither, check that you're using the rigth path for the file and that the server is running.

Test that ZEND is running. You should have an ZEND Controller icon, which may be used, or you can access it from your menu.

Test that the database is running. Open phpmyadmin. If that doesn't work, I would assume that you have failed to install phpmyadmin, but I'm unable to advise further for now. Create a new (empty) database to be used for with php-fusion.

Test the debugger by starting eclipse.com. Test it on the example above " stest.php " or any orther small php program. Just to ensure it's properly installed and functioning.

Installling php-fusion locally
There are two approaches. Either you want to install a clean php-fusion from scratch, or you want to install an existing php-fusion application running somewhere else.

In either case I suggest to install it in a subdirectory under the htdocs directory. This will allow you to keep track of several projects, by having each in separate directories.

Clean installation:
Copy all php-fusion files (core+language) to the appropriate directory


Rename: _config.php to config.php


Open your browser and type (provided that you have created a directory called PF7 for your files:


Localhost:/PF7


Complete the installation, as you would do on any host, by providing the host (localhost), database name, database user and database password


Delete: setup.php



This worked for me in the first try. The usual chmod steps are skipped in a Windows environment.

Copy installation:

Copy all files to the appropriate directory


Modify config.php to suit your new password etc


Export the database from your existing installation using phpmyadmin


Import the database in your local mySQL using phpmyadmin


Start debugging

Create a new project (File-New-PHP Project) pointing to your php-fusion source.

Eclipse works with something called Run or Debug configurations. Obviously a Debug configuration is used when you want to debug (stop execution on its way), and a Run configuration otherwise.

In its standard configuration Eclipse will write output to a console window as well as a browser window in the debugger. The console window may be helpful if you want to get a grip of tags etc. The browser window does leaves the output in a standard-html way of formatting and is further small (although it can be adjustedin size).

It took me a while to figure out how to set up Eclipse to show output in my preferred web-browser. First, you have to select your preferred web browser under Window-Web browser. Then, you have to create a new Debug configuration. Select Run-Debug congigurations. Create a new configuration by clicking on the New configuration icon in the upper left corner and prepare a "PHP Web Page" configuration, opposite to a "PHP Script" configuration. That solved it for me.

If you have been able to follow me so far, you should be able to set breakpoints in any php-fusion file, and use your web browser to run php-fusion and navigate around. By default execution in the debugger stops at every time a new file is launched, so you'll have to press continue.

Looking forward to hear about your experiences...
Ads
Share This News
AddThis:
URL:
BBcode:
HTML:

Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.
Ratings
Current Rating: (Total: 6 ratings)   

Current Average Rating: 4.83 Stars
Rating are available to Members only.
Please login or register to vote.

Users Online
Total Posts: 5425 :: Total Threads: 493 :: Total Comments: 150
· Guests Online: 4
· Members Online: 0
· Total Members: 2,243
· Newest Member: Captain Ringo
· Members who have visited today:
fawwaz, wolfbbs, OutLawer, legion13, raho0ol, Captain Ringo, Bones, Hazarth
Birthdays This Month
· Birthdays This Month:
17/09 - Captain Ringo 10/09 - Blackstyler 23/09 - nerazzurcho 27/09 - Peisi 07/09 - Van Damm 14/09 - tsknutsen 19/09 - InsatiableKisses 08/09 - UniCoRN 08/09 - jebajseti 28/09 - Kor Saphire 26/09 - Meric79 21/09 - behrooz 07/09 - Kyo 07/09 - EphyxHU 27/09 - lushenko 16/09 - kokken 26/09 - Anette 06/09 - wildhaggis
Render time: 0.19 seconds 744,592 unique visits Top