Getting Xampp working with VS.Php for Visual Studio
Many customers have asked me how to configure Xampp to work with VS.Php. Tonight, I went through the process of doing this and documented each step so you don't have to figure this out by yourself.
Installing Xampp
The first step is to decide where to install Xampp. I decided to go with the default location. A lot of further steps assume this location. If you pick a different location make sure you take this into consideration.
The next step is choosing what components to install. I chose Apache and MySql servers. I also wanted to install them as services.
In my system, I already have IIS install. This means that Apache is going to fail to start because it is trying to use port 80.
So I went to the httpd.conf and changed the listening port to port 8080. If don't have IIS installed, don't do this.
The next step is to enable XDebug in PHP. To do this, I need to update php.ini and insert the following text:
Please note that the path to the xdebug.dll needs to be the full path. Also, the version of Xampp that I installed uses PHP 5.3 so I'm using the Xdebug version for PHP 5.3 as the path to the dll specifies the version of PHP.
For convenience, here is the text you need to paste into the file:
|
zend_extension="C:\Program Files (x86)\Jcx.Software\VS.Php\2010\php 5.3\ext\php_xdebug.dll"
;;;;;;;;;;;;;;;;;;; ; Module Settings ; ;;;;;;;;;;;;;;;;;;; [XDebug] xdebug.idekey = vsphp xdebug.remote_enable = 1 xdebug.remote_host = 127.0.0.1 xdebug.remote_port = 7870 xdebug.remote_autostart = 1 |
At this point it is a good time to restart Apache using the Xampp tool:
Once you restart Apache, you are ready to create a new project and start using the PHP debugger in VS.Php.
I'm going to create a simple project but you could potentially create a project from existing folder if you are going to start from something you already have.
The key at this point is to create a project under Apache's document root location.
Note that I'm creating a PHP 5.3 project since Xampp is using PHP 5.3. Also I unchecked the "Create directory for solution". This means that my project will be created right under the htdocs directory as a subdirectory.
The next step is to tell the project not to use the built-in web server and instead use Xampp.
I changed the debug mode into External Mode. Then updated the start URL to point to the Xampp server.
Now when I hit F5, the debugger can let you step into the code:
That's all you need to do to get Xampp working with VS.Php. If you have further questions please post a comment on this blog.
Juan
- juanc's blog
- Login or register to post comments
jowi says:
I tried this step by step, when i hit F5 it uses my xamp apache server at localhost:8080, but it does not stop on breakpoints...
Using the internal vs.php apache server does work like it should.
Which php.ini do i need to change? The one in xamp's php folder?
Do i need to specify a specific php.ini in the project configuration? Once i use 'external mode' that option is gone?
I'm using VS2010 on Windows 7 (64 bits). I've installed the latest VS.php, and i'm using XAMPP Lite version 1.7.7.
jowi says:
Fixed it, probably for running Apache/php under Windows 7/64 you *must* use the thread safe version of php. Using the threadsafe version of php-5.3.4-Win32-VC6-x86.msi fixed it, now i can debug from inside VS2010 using my external Apache/PHP config :)
GedK says:
I had the same problem but the above steps did not work for me. However I fixed it by going to this URL and following the instructions there:
http://www.xdebug.org/find-binary.php
cyberbeing says:
Hi,
Will the Vs.php configuration for Xampp work for Wamp too?
juanc says:
Yes it should.
kyt says:
I've followed these instructions and I'm having issues getting the breakpoints to trigger for Firefox 8. Internet Explorer works fine, but not Firefox.
juanc says:
That's probably because the Xdebug session cookie is not getting set or is been reset somehow.
If your code messes up with session cookies, it could be removing this cookie and that's the source of the problem.
Juan
ihs says:
Very concise, clear and easy to follow guide for a very useful setting. Thanks a lot!