Supporting PHP and PEAR in Visual Studio

I was very recently asked to lend my support for maintaining a website we have which is written in PHP. Now normally I’d run straight off to my trusty little 2010 macbook (which, by the way, has NOT degraded in speed in all that time nor does it require constant reboots..do you hear that windows? I digress) and use any one of the free or cheap plethora of tools to help with this task. Personally I tend to use Aptana Studio. Just for once I thought I would try and leverage my normal windows work machine for this task and so I turned straight to Visual Studio. It turns out that there is an add-on for studio made by the guys at Devsense. So using the Visual Studio Extensions and Updates manager I installed the add in called ‘PHP Tools for VS 2013’ (which is on a 30 day trial) and awaited the amazingness…..

Time passed and true amazingness did not happen and so I decided that I would just get on with my work instead.

I downloaded the source for the website put it onto my machine and then started the process. As the project is an already existing site i needed to run the ‘Project From Existing Code’ menu item available from the File/New menu item. This takes you through a simple wizard and at the end of this process you have a visual studio project with all of your PHP code. Great, so now down to it…. Unfortunately what I did not realise was that this site made use of PEAR extensions, thus everytime i tried to run a page with email capabilities it would just break unable to resolve the necessary libraries.

So to install pear i followed this superb and simply written article, in a nutshell:-

1. Download this pear application archive and save it into your PHP application directory.

2. Instantiate a new Command window as an administrator and change the working directory to your PHP installation directory (I.e. cd c:\php).

3. Initiate the following command line to start the pear go-pear.phar.

Go Pear

4. You will be asked if you wanted to install local or system, I elected to install for system and to confirm that paths. I pressed enter as I did not want to change any paths at all. Once the set up was complete I also elected to add the registry entry that is displayed towards the end of the set up. A simple click of the specified .reg file located in the PHP application was all that was required.

5. Once pear has finished installing I knew that in order to get my site working I needed to install the Mail and Mail Mime packages; this was achieved though use of the following command lines:-

Mail

mail_mime

And voila, I can now debug and run my PHP application, error free and all Visual Studio stylee with all of the goodies that this environment brings.