Visual Studio 2008 and PHP Coloring
Originally published on my old blog at cumps.be on August 8, 2007.
Visual Studio is a great editor! But when editing other file formats I miss the coloring.
When working with PHP files, it’s great to be able to make a solution to organize php sources, and having code open in tabs, but when they all look black and white, I find it requires more focus on my part when coding.
Long ago, I wrote a piece on getting coloring to work in Visual Studio 2002 and 2003. Somehow I managed to skip doing any PHP development during the entire lifetime of Visual Studio 2005, but recently I had to create something small, and I missed my nice colors. I tried to apply my old method in Visual Studio 2008 (Orcas), and this is the result:

Looks pretty appetizing, doesn’t it?
To get this in Visual Studio 2008, do the following:
- Download **[vs-php.zip](vs-php.zip)** and extract it somewhere.
- Execute the preferred registry file (php_edit2008.reg for Visual Studio 2008 ofcourse).
- This will create a File Extension association for PHP files, treating them as C++ files.
- Copy the **usertype.dat** to your VS.NET directory. (default C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE)
- Restart Visual Studio if it was opened.
- Open a .php file and admire the colors!

When you look in the registry, you will see that the .php extension looks exactly like the .cpp one, you can also try experimenting with applying the .cs or .html filter to a .php file, but I found them both lacking. Using the .cs value, you will get coloring from C#, but it will also give you lots of syntax warnings. When using the .html one, it doesn’t always color the entire file.
If you want to color more keywords, open up the usertype.dat file in a text editor, and simply add more words to it.
Enjoy the extra productivity gain!
You May Also Like
ConvertToProperties Macro
For everyone who received .NET Magazine 5, there's an article in there at page 53 about cleaning up your code.
Using DebugView and C#
DebugView is a very nice tool from Microsoft (by SysInternals), which allows you to see debug output from the kernel or Win32, local and remote!
Search File Contents
When using the Windows Search functionality, you can search for words inside files. By default this doesn't seem to work for .sql or .php files however.



