Using WebMatrix to Develop Apps with PEAR Modules

If you’re developing PHP on Windows, Microsoft has an IDE that may be of some interest to you, it’s called WebMatrix. WebMatrix is an extremely powerful IDE providing code highlighting for PHP, Node.js, ASP.NET Razor, it even offers code completion for popular OSS CMS platforms like WordPress, Drupal and Joomla. Unlike conventional IDE’s it’s extremely lightweight, despite it’s heavy hitting features.

One of the oddities of WebMatrix is that is installs it’s own copy of php on your system located in C:\Program Files (x86)\IIS Express\PHP. Normally not a big deal, however if you start building larger applications you’ll probably want to include some functionality which will require a Pear package. This isn’t as straight forward as one would hope.

Installing Pear in WebMatrix

Before I send you down a wild goose chase, you can validate that WebMatrix is actually using the php.ini file from it’s own installation, you can do this by including <?php phpinfo(); ?> in one of your php files then run the site. I have also assumed that you have already installed Pear using the instructions.

When the PHP Information loads you’ll want to check two of the variables first check Loaded Configuration File this will tell you the path of the php.ini file it is reading the configuration information from. Second, you’ll want to check out include_path which will print out the include paths that it will check for addition application code blocks, such as Pear Packages by default this will be .;C:\php\pear.

Finding the Pear directory on your machine

To find the path to Pear on your machine open up the command prompt and type pear config-get php_dir, copy the path that is outputted and close the window.

In order to change the php.ini file, you’ll need to open Notepad with elevated permissions this is due to the file being contained in the Program Files directory which is protected by the Operating System.  Once you have opened the WebMatrix php.ini file from C:\Program Files (x86)\IIS Express\PHP\v5.3 scroll to the bottom of the file and add include_path=".;C:\Path\From\Pear\Config\Output\"

Oh Great, I did all that and it still doesn’t work

Before you go and brush your shoulders off, you need to restart IIS Express. The php.ini file is only loaded when the IIS Express process is started, there is no file system watcher set up to monitor changes to the php.ini file.

Restart IIS Express by clicking on the blue circular arrow (marked restart) in the Sites tray of the WebMatrix Home Ribbon.