How to setup PHP debugging in Eclipse – xDebug

The following video tutorial shows how to configure Xdebug delivered with XAMPP and how to use Eclipse PDT for debugging a sample php
project. The video is covered by the written instructions below, see them as addition, the video should be enough. One note to the end of the
video: The debugging is started twice, in the first debug pass you will see, that the website is not redirected to the php script receiving the
form data. That sometimes just happens, seems to be some kind of bug. On the second attempt everything works.


The tutorial uses XAMPP 1.7.3, Xdebug 2.0.6-dev, Eclipse PDT 2.2.0 All In Ones and Windows 7. It however should work the same on future
versions of the mentioned software. The written instructions assume that you install XAMPP to C: (the default suggested by the installer). Note
that the installer then creates C:xampp automatically.

1) Get XAMPP (the basic package, only this package includes Xdebug) from
http://www.apachefriends.org/en/xampp-windows.html. Install it to C:,
the installer will then automatically create C:xampp

2) After XAMPP has
been installed, open C:xamppphpphp.ini and perform the following
replacements:

replace
;zend_extension = “C:xamppphpextphp_xdebug.dll”
with
zend_extension = “C:xamppphpextphp_xdebug.dll”

replace
;xdebug.remote_enable = 0
with
xdebug.remote_enable = 1

3) (Re)start the apache webserver using the XAMPP Control Panel.

4) Get Eclipse PDT All In Ones from
http://www.eclipse.org/pdt/downloads/ and extract it to a folder of your choice. Start Eclipse and make sure to select C:xampphtdocs as workspace, else your files won’t be available to the apache webserver and therefore you can’t execute them. In the Eclipse menu choose Window
– Preferences, then PHP – Debug. Change the PHP Debugger from Zend Debugger to XDebug and uncheck “Break at First Line”. Click Apply and
then OK. The debugger is now set up. Time to use it! IMPORTANT: If you already had any debug configuration for a PHP project, make sure to
delete it, so that a new configuration with the new settings is created the next time you debug a php script! Debug configurations you’ve
created before changing the settings in this step won’t be automatically updated! This is a common source of errors!

5) (For this step I recommend you have a look at the video, it is easy but complex to describe).
If you haven’t already done it, choose the most right symbol with the arrow (Workbench) in the Eclipse welcome screen. In the Eclipse menu choose File – New – PHP Project. Enter a name for your project e.g. WebDebugTest and click Finish. Now download http://download.boulder.ibm.com/ibmdl/pub/software/dw/opensource/os-php-eclipse-pdt-debug_source.zip
, it includes a sample project (not done by me, it is from [1]) called “webDebugExample”. Select the three files from this folder and add them to your Eclipse project by using e.g. Drag&Drop (maybe have a look at the video if you don’t know how to do that). The file one should start from when using this sample is “enterGreeting.php”. This script then sends the data you input to its form to “results.php”. Set a breakpoint in the “results.php” on line 8, then make sure to select “enterGreeting.php” in eclipse and debug the project as PHP Web Page. After you have entered something in the form and choosen submit, the debugger should start. The debugger is used like the other typical debuggers you may know. If you want to see the output of the script, you have to continue it using the arrow symbol in the debugger. Note, that in some cases the displayed website won’t change from the input form to the output. This is why the debugging process is run twice in the video. This seems to be a bug using Eclipse PDT and XDebug.

How to enable autocomplete for CodeIgniter in Eclipse

To enable auto-complete for a project say Project1, these two steps need to be done.

1. Step 1:- Make a code base folder

Download CodeIgniter and rename its folder to BASE.  Add the following in two files (Controller.php and Model.php) in the sytem->core right after the open brackets of the respective class:

/**
  * @var CI_Config
  */
 var $config;
 /**
  * @var CI_DB_active_record
  */
 var $db;
 /**
  * @var CI_Email
  */
 var $email;
 /**
  * @var CI_Form_validation
  */
 var $form_validation;
 /**
  * @var CI_Input
  */
 var $input;
 /**
  * @var CI_Loader
  */
 var $load;
 /**
  * @var CI_Router
  */
 var $router;
 /**
  * @var CI_Session
  */
 var $session;
 /**
  * @var CI_Table
  */
 var $table;
 /**
  * @var CI_Unit_test
  */
 var $unit;
 /**
  * @var CI_URI
  */
 var $uri;
 /**
  * @var CI_Pagination
  */
 var $pagination;

2. Step 2:- Copy two folders to a single folder

 

Now create a new folder (say ci ) and copy this folder BASE and your code files Project1 to it.
Open your new folder (ci) in Eclipse and right click Project1, click Include Path -> Projects -> Add and check BASE -> OK.

Now you should be able to see auto complete in action, if necessary restart Eclipse.

 

 

Reference : http://taggedzi.com/articles/display/autocomplete-eclipse-codeigniter-2

How to setup VisualSVN Server and TortoiseSVN Client

1. Install TortoiseSVN Client

Install the above client from http://tortoisesvn.net/downloads.html which is a straight forward installation.

2. Install VisualSVN Server

Install this server from http://www.visualsvn.com/server/download/

Now open the server by clicking the icon from desktop etc and create a repository. After the repository is created right click its name in the right panel and click ‘Copy url to clipboard’. Right Click on the folder that you want to upload to this repository from your computer and from the context menu choose TortoiseSVN -> import and paste the url in the repository box. Click Ok to upload your code to the repository.

Now clicking on the same folder you can update, commit your changes.

How to setup Virtual Host on XAMP for CodeIgniter

Virtual Hosts

Virtual Hosts give you the ability to “host” more than one Web site and domain on your computer. With a virtual host you can have separate local domain names for each of your Web sites: for example, http://clientA/ for one site and http://clientB/ for another. When you type the URL for the Virtual Host in your Web browser, the browser doesn’t go out onto the internet to find the site, but instead asks for the proper file from the Web server running on your computer. Not only does a Virtual Host let you run multiple Web sites on your computer, but it also lets you store the files for those sites anywhere on your computer and not just in the C:/XAMPP/htdocs folder.

Adding a Virtual Host is a 2-step process:

1. Add a new entry to your computer’s hosts file.

open the hosts file located at C:/windows/system32/drivers/etc/hosts. At the end of this file add:

127.0.0.1      clientA.local

Where clientA.local is the name that you would use to access your site and can be anything but personally I like this convention:
websitename.local, so if you want to browse the site on internet you have to only change .local by .com or .se etc and looking at the same page.

2. Edit the Apache configuration file

In Notepad open the Apache configuration file located at C:/xampp/apache/conf/extra/httpd-vhosts.conf
At the bottom of that file add:

NameVirtualHost *
<VirtualHost *>
   DocumentRoot "C:/xampp/htdocs"
   ServerName localhost
</VirtualHost>
<VirtualHost *>
   DocumentRoot "C:/Documents and Settings/MyclientAwebsite"
   ServerName clientA.local
   <Directory "C:/Documents and Settings/MyclientAwebsite">
      Order allow,deny
      Allow from all
   </Directory>
</VirtualHost>

The first 5 lines are mandatory as you will be accessing phpmyadmin. The next lines between <VirtualHost *> and </VirtualHost> adds one virtual host and you can add as many as you need.

The DocumentRoot points to the directory of your website files. While ServerName is again the name that you would write in the address bar of your browser. The rest is just access control list and should remain intact.

For CodeIgniter I recommend this clientA.local* instead of clientA.local. The star (*) enable you to prevent any object not found errors later.

Restart Apache.