Quick Way to Integrate PhpED and Team Foundation Server
So when I’m asked, “How can I integrate my PHP IDE with Team Foundation Server?”, my first response *should* be, “Why not use Visual Studio instead?” That’s an idealistic reply, admittedly. There are several great tools out there for PHP development, with followings that would collectively shudder at the thought of *having* to use Visual Studio.
PhpED by NuSphere is a popular PHP development tool. It boasts (among a lot of other things) the ability to plug-in to various version control systems, although it comes set up to leverage CVS. There’s not much documentation out there to explain how exactly to tie into other version control systems besides CVS. So what about Team Foundation Server?
The fast answer? Use the TFS Power Tools, more specifically the Windows Explorer extension. This power tool allows you to perform version control operations on files directly from Windows Explorer:
All that’s really required (besides having the TFS Power Tools installed) is that the files you want to work on reside in a folder that’s in a TFS workspace.
If you use PhpED for PHP development, you probably see where I’m going with this. ;)
Let’s say I have the below workspace and project in PhpED:
I set up this project in C:\Work\NotDotNet\Test, which is already mapped to a TFS workspace. As soon as I start populating files into this project, I can see that the Windows Explorer extension power tool is already working if I look at the file system:
Now for the fun part. PhpED has a nifty little feature that allows you to access the Windows shell from within its IDE. Right-click, select “Shell Menu”, and there it is!
To add all these files to TFS version control, I right-click the project and select Shell Menu->Team Foundation Server->Add.
The “Add to Source Control” dialog pops up:
Hit “Finish”, and I’ve added all my files as pending changes to TFS. Last, all I have to do is check them in by again going to the Shell Menu, only this time selecting “Check In”.
That gives me the TFS check-in dialog we all know and love. I can do everything I normally would with this dialog, such as choosing specific files to check in, comments, check-in notes, and linking to work items.
Click “Check In” and I’m done (in my case, check check-in created changeset 270)!
BTW, notice I’m getting the TFS version control icons displayed in PhpED (the green triangles in at the bottom-right of an item’s icon indicates it’s “seen” by TFS, a pencil indicates a checked-out file, etc.):
Now to test that I can check out and check in, let’s make a little change. (My big preface here is that I know almost nothing about PHP development, so I’m just going to insert some arbitrary text so I have a modification. This is not a PHP lesson!)
First, I noticed that PhpED won’t even let me modify a file (may be a setting somewhere, but I’m not sure) if it’s read-only. So that tells me right away that my file is not checked out.
So I check out the file via the Shell Menu extension (Shell Menu->Team Foundation Server->Check Out for Edit).
Now I can make a small change.
Once I’m done making my edits, I save the file and check it in (again using the Shell Menu, you probably get this by now).
Again, I get the beloved check-in dialog again.
Fill in the information I want, click “Check In”, and I’m off!
Now, just to make sure I’m not looking at smoke and mirrors, let’s switch to Team Explorer and view the file’s history.
There’s my change! Now, for a final check, let me diff the two versions.
Make sense? Not bad for a free integration point!
Now, this all said, there is one main caveat which is worth mentioning – it shouldn’t prevent you from leveraging this shell-type integration, but it should be known nonetheless. The TFS Power Tool shell extension only provides the basic version control operations. Others, such as getting historical versions, viewing history, branching, merging, and shelving are notably absent from the shell extension’s menu. You can still do all this from Team Explorer – you’ll have this installed on your machine, as it’s a requirement for the TFS Power Tools to be installed. So yes, for some operations you’ll need to pop open Team Explorer, but the bulk of your daily operations are available right from the shell.
BUT, PhpED is also has a very extensible menu system (that’s how it ties in with CVS), so you may also be able to leverage that to create TFS-specific menu options (such as creating workspaces, diffing files, etc.). I had a little fun with this and was able to quite easily create a couple of TFS-related menu options to help me view a file’s history, as well as create a shelf. All I did was drop the path to tf.exe (by default it’s "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ ”) into my PATH environment variable (just easier than putting in the full path to tf.exe each time), and away I went.
In PhpED, go to Tools->Settings, then scroll down to Integration under Tools. Here I created a new menu called “Team Foundation Server” and added a few submenu items with the following options (I’m sure you can figure out how to add a few more if you want):
Option Name | Command | Options Selected |
View History | tf history “@FName@” |
|
Shelve | tf shelve |
|
Annotate |
tfpt annotate “@FName@” |
|
And I end up with this:
As you can see, I can leverage the command-line interface for both Team Explorer (tf.exe) and the Power Tools (tfpt.exe, which gets added to your PATH automatically upon installation).
So now, when I right-click on certain objects in PhpED, I can take advantage of these options. They simply shell out the specified commands and the appropriate CLI takes over. For example, if I select “View History”,
I get this:
Sweet!
So that’s about it! There of course may be other ways to integrate these two products (perhaps using SVNBridge on CodePlex), but I found this above method to be quick and relatively painless.
I hope this helps a couple people! Please let me know what you think, or if you have any questions.
Comments
Anonymous
April 14, 2010
This would be a fantastic article if you could point me in the direction of how to get over this initial hurdle: "All that’s really required (besides having the TFS Power Tools installed) is that the files you want to work on reside in a folder that’s in a TFS workspace" How do you create a TFS workspace and link it to a mapped folder on the client machine for non-VS projects (like phpEd)?Anonymous
May 28, 2010
Hi Kelley, The easiest way is to install Team Explorer on your machine to set up your initial workspace mappings. (You'll have the rights to install Team Explorer if you have a CAL for TFS.) BTW - sorry for the tardy reply. Email notification didn't work for this comment, so I just now noticed it. Thanks for reading!Anonymous
February 02, 2014
Have followed these instructions and have TFS power tools working in windows explorer. However, NuSphere does not pick up the Team Foundation Server menu option under "shell menu" for my workspace. Running TFS 2013 powertools against TFS in the Cloud and Nusphere 6.2 on Windows 7. Any ideas?