Symfony Development using Textmate
Par NiKo le mercredi 16 décembre 2009, 08:45 - Dev
- Lien permanent -
21 commentaires -
Tags :
When I do consulting, a lot of people are really surprised that I use Texmate, a popular text editor for OS X, to develop on Symfony projects. Indeed, Textmate is a bit rough around the edge compared to bloated full featured IDE like Eclipse PDT or Netbeans, which are both Java based by the way.
So why using Textmate? No intelligent autocompletion, very basic project management, poor VCS native support, limited index search capabilities… First and while it’s mainly a matter of taste, I mainly use Texmate because it’s fast. Compared to PDT with which you often have to wait a bunch of seconds for the UI to respond on some action you make, mate will react quite instantaneously, and that is making big difference to me. Because when I’m concentrated, focused on some complex problem to solve, I demand my text editor to not make me wait [1].
Oppositely, not having full code introspection and autocompletion makes mate making me think about the code I write, instead of just consuming some API passively. I’ve been using phpeclipse and PDT for some years with Symfony, but I think I really began to understand the framework architecture when I switched to mate as my primary editor. Because every time you need to do something with the Symfony API, you have to open the file and read the code: then you learn a lot. And by the time, you end by knowing the core very well, and it’s incredibly efficient. One more time, this is just matter of taste.
Textmate quick tips
So whereas mate can be somewhat limited at first glance, a second look shows it provides some really effective commands to enhance your productivity. Let’s examine some of them.
Searching for a file within the project codebase
Just by pressing ⌘ + t, a snappy filename search window will pop up and allow you to search a file interactively by its name pattern. If you’re using the incredible Quicksilver app for osx, you got the picture.

As Symfony names php files against the class name they contain, finding a class file is just easy as typing the class name in the search field!
Browsing the available functions, classes and methods within a php file
When a php file is opened, the ⌘ + shift + t command will show up the available sections of the document, with a search box you can use to filter their names, still interactively.

Note that this will also work for other file types (like CSS for instance).
Obtening help on native php functions
Move the carret onto some php native function and press ctrl + h and you’ll get the php.net related page in a pop up.
Want the function signature definition in a tooltip, like in PDT or Netbeans? Hit ⌥ + F1 and you’re done.

Using the mate command line utility
Textmate ships with a native command line interface executable called mate you can use from your term:
$ cd /path/to/project $ mate .
You can also pipe some command to mate to open the output in it:
$ svn diff|mate

Taking part of Mate’s url-scheme capabilities with Symfony
I already blogged about this awesome feature available since Symfony 1.3, one more I won’t ever be able to live without.
Improve your productivity using bundles
The Ack in project bundle
One of the most annoying lack of mate is its internal search engine. It’s really damn slow. The best way to get something decent is to install the Ack in project bundle. You’ll then be able to access a fast and convenient fulltext search engine by pressing the ⌘ + shift + a command.

The ProjectPlus bundle
If you’re looking after a better project browser and some VCS support in mate, you’ll love the ProjectPlus bundle. It will replace the default project drawer by a new one with finder label colors support, file sorting options and VCS icons integration. Give it a try, you won’t be able to live without it.

The Symfony bundle
How could I write a blog post on Textmate and Symfony without mentioning the Symfony bundle? Denderello and contributors did a really good job taking over the original tool, which provides very convenient and effective shortcuts to write Symfony snippets of code quickly.
The GetBundle bundle
Last, if you didn’t find anything new or useful reading this blog entry, you might then be interested by installing the GetBundle bundle which will allow you to browse all available bundles and install any of them in one click!

Conclusion
So these are some of the reasons why I’m using Textmate when developing with Symfony (and other languages too). What are yours?
Notes
[1] You know the don’t make me think
mantra? Well, now you got another one 
21 commentaires (Ajouter un commentaire)
Hey, I've been a heavy desktop user of Ubuntu, remember?
But as I often tell to people asking, having a baby not making his night for 13 consecutive months makes the perspective of maintaining a desktop linux (at the time) something not really /wishable/
Though I'm running 'buntu in Parallels Desktop for some linux dedicated work and it's definitely nice, I agree.
I don't know how you could prefer OSX to a good ol' Gnome
3 years running at our office 5 dist-upgrade and still rocking.
Nicolas> I don't understand the problem: when I run "Install Blundle" or "Show Bundles on Repository" (e.g.) a message says that for SVN I must install Rosetta.
Doesn't matter, I use few bundles.. git and svn rulez!
Alex (and Tom) thanks for sharing the tips..
Sorry pals, my antispam was a bit nervous, I stressed it down.
Jérôme> The main reasons why I switched to Mac were 1) OS powers and stability (BSD based!), 2) efficient ACPI, and 3) rock solid harware. But I must admit I miss my ubuntu everyday for some cool stuff like apt...
Merci N1K0, super utile ton billet. Je vais enrichir mon TextMate de ce pas
I wrote a comment that does not appear... it that normal ?
To sum up my -ghost- comment :
* I switched from Eclipse to NetBeans recently
* It's fast enough, and provides 200% custom shortcuts (dialog to open resource/class/file)
* I use my custom Sensio Labs color scheme (provided on my blog)
* But TxtMate is useful to be called by command line, almost as fast as my custom emacs
But thanks anyway for your interesting points, I'm gonna try the bundles !
+1 for Tenshu. With my recent change of job, i return back to a PC with Ubuntu installed. So.. no Textmate.
I discovered Netbeans and I use it on my mac too now. And with our new computers, after the analysis, it's very lightweight.
@palleas you shoud try ReMate http://ciaranwal.sh/remate/
I had the same problem than yours with the "refresh on focus" with NFS Volumes containing lot of files.
With ReMate, you can disable this refresh on focus.
Sorry but i'm using Netbeans while i was using Gedit.
Version 6.8 is a looot faster ... After the project analysis sequence.
Symfony support is cool : switch to view, switch to action, go to definition, cli...
It's a young project (php in netbeans) but it is a really really good start.
The general emphasis of the comments makes me think that working with OSX (opt. with TextMate) is almost the rule now for web developers. My thought can appear naive but remember that wasn't the case 3 or 4 years before.
Could be a nice article to read/write on how Apple's marketing service has convinced open source developers to buy significantly more expensive hardware than competitors in order to run non-free softwares on a quite short time...
Personally, I'm still stuck to Debian/Ubuntu with fat PDT(*) but I must admit that my last visit to an Apple Store nearly ended with a credit card explosion
(*) Recently started a positive try with netbeans.
Great post! I've been using TextMate + symfony for years and still learned some new tricks with this one.
One of the things we use at P'unk Ave (thanks to Tom Boutell) is a little script called mateclass:
#!/bin/sh
class=${1//_/\/}
mate `find . | grep -v \.svn | grep "\($class\.php\|$class\.class\.php\)"`
Kind of like the cmd+t trick but from the terminal.
Using textmate for quite a long time now!
To Palleas and people using textmate to edit files remotely (sshfs & stuff), i recommend ReMate (http://ciaranwal.sh/remate/) which add an option in mate to disable refresh of the project each time it gains focus again, pretty useful.
Interesting reasons...
I recently switched form Eclipse to NetBeans, mostly because it's faster and provides some useful tricks for symfony projects.
It gives me all I need : great Subversion/Git support, 200% custom keyboard shortcuts, XDebug integration and debugging tools, Hudson integration, and obviously classical "Go to source / symbol" features.
I tried to switch to Textmate anyway, but...
1/ It's not free
2/ Yes it's fast, but Netbeans is not so slow once you disabled "useless" features
3/ Yes color scheme is cool, but I made a custom "sensio labs color sheme" for NeBeans (look at my website :-] )
Well, I still have have a TextMate on my system anyway to edit files quickly... TextMate is launch almost as fast as my custom Emacs...
Once again, really nice to read your points anyway
I agree, text editors make you dive into code. This is helpful if you want to understand, rather than just "write code using", <insert_your_favorite_framework_here>
Textmate is non-free and mac-only
GNU/Linux users can try gedit, kate, geany...
Moreweb> Hmm, as far as I can remember, mate provides native SVN support, why do you need to install some supplementary bundle?
Thanks Nicolas, some useful tips!
GetBundle requires Rosetta on Snow Leopard (for svn).
@palleas : you should try ReMate http://ciaranwal.sh/remate/
It disables the auto refresh of textmate when it regains the focus (I had the same problem than you with nfs volumes)
NicoH> Yes, nice tools but mate is currently the best synthesis between IDE and text editor to me.
For those who are interested, Komodo Edit can be something to try out, too.
Did you try Coda or Espresso?
Textmate FTW!
I use it because it is simple : it only do what I need him to do. I'm using a few bundles too :
- Symfony
- Copy as RTF (usefull to make slides w/ code)
- Ack in project (since this morning, actually)
There is one simple issue when you have to work an a distant server (share with Samba, I'm my case), Textmate re-indexe all the files of the project, so it sometime freezes.
Lucky for me, most of my work is made locally (AMP w/ macport) so it's no big deal...
I can't use Eclipse or Netbeans anymore to do PHP development...
I'm using mate because it's fast, damn fast. Last months I gave a try to netbeans, but having my CPU usage to 100% all 20 minutes was very annoying.
I'm missing one thing in mate, the goto declaration. It was very useful to browse the source code of symfony.
Perhaps I should give a try to the ViewCode plugin of Kris in the debug toolbar.
By the way, thanks for the tips !
La discussion continue ailleurs
Social comments and analytics for this post
This post was mentioned on Twitter by n1k0: [blog] Symfony Development using Textmate http://n1k.li/sfmate...