PHP code completion in TextMate
Alongside Flex Builder 2, TextMate is my editor of choice on OS X.
TextMate is a great all-round editor for simple (and some not-so-simple) tasks. For RoR, it's the dog's bullocks. I was, however, initially somewhat disappointed by its support for PHP.
Out of the box, TextMate doesn't support PHP code completion or provide you with an easy method of accessing the PHP documentation. I found, however, that you can easily configure it to do both of these things by downloading, installing and configuring the PHP Code Completion bundle.
Code completion
To set up code completion in TextMate, you must first download the PHP Code Completion bundle. As you can see, that link leads to an SVN repository.
To download and install the PHP code completion bundle, follow these instructions:
- Open Terminal
- Create a folder under /Library/Application Support/ called TextMate and a folder under that called /Bundles:
mkdir -p /Library/Application\ Support/TextMate/Bundles
- Switch to that folder:
cd /Library/Application\ Support/TextMate/Bundles
- Check out the bundle you want from the TextMate bundles repository:
svn co http://macromates.com/svn/Bundles/trunk/Bundles/PHPCodeCompletion.tmbundle
- If you had TextMate open during this, select Bundles → Bundle Editor → Reload Bundles.
Create a new PHP file and test out the code completion by typing the first few letters of a function name and pressing ⎋ (esc). If you press ⌥ F1 before code completion, you will see a list of similar functions and if you press it after completion, you will see some brief documentation on the function signature.
Documentation
The PHP docs are probably the best I've seen for any programming language. The online version with comments is especially useful. Although TextMate doesn't have a built-in feature in the default bundles to access this documentation, the PHP code completion bundle you just installed does. It does require some configuration though.
With the PHP code completion bundle installed, you can access the PHP documentation by pressing Shift F1. The first time you do this, you will see a message telling you that you need to configure your settings.
To configure the PHP documentation:
- If you don't already have it, download the PHP documentation (.tar.gz version) to your computer. I placed the .tar.gz file in
/Users/aral/library/PHP_Manual/
and unzipped it there. The unzipped files appear in an html folder so the path I entered in my preferences (see Step 4, below) was/Users/aral/library/PHP_Manual/html/
(do not leave out the trailing forward slash or else it won't work). Also, wherever you decide to place the documentaiton, make sure that none of the folder names on its path have a space in them. - Click the Edit Preferences link in the PHPCodeCompletion Documentation window to open the PHPCodeCompletion preferences file in TextMate.
- Comment out the line that reads
$phpcc_configured = FALSE;
and uncomment the one that sets the same flag to true. - Set the path that you placed the documentation in to the value of the
$phpcc_manual_path_to_local
variable. - Save and close the preferences file.
Press Shift F1 on a function name to test out the documentation. If you see the familiar PHP web site appear, it means that you put the wrong path in the preferences file and that you are viewing the online docs as a backup. Of course, you may want to default to the online docs as they contain those invaluable user-submitted comments but it does make things slightly slower too.
That's it! You should now have code completion and documentation working for PHP in TextMate. Enjoy! :)
Comments
by kevin on 2007-01-07 04:03:39
by Rob McMichael on 2007-01-08 11:47:10
by kevin on 2007-01-08 16:09:12
by John Joyce on 2007-01-19 23:25:58
by George on 2007-03-27 10:41:26
by TextMate - text editor for MacOSX « Kenjun on 2007-04-12 13:13:21
by Brian on 2007-05-06 05:32:19
by Chris on 2007-05-07 19:45:11
by TextMateでPHPマニュアルを参照するBundle « ZerockBlog on 2007-05-13 04:53:24
by Matt on 2007-05-18 18:43:54
by Matt on 2007-05-18 18:46:24
by Nick on 2007-05-22 03:36:14
by hsyn on 2007-05-22 08:54:02
by Netbeans vs TextMate — Josh Kim dot Org on 2007-08-30 04:06:05
by Allan Odgaard on 2007-10-23 13:19:24
by Aral on 2007-10-23 17:51:50
by Sam on 2008-06-27 06:47:39
by Adam on 2008-09-03 07:22:40
by Alexandra on 2008-03-30 21:04:53
by Sergio on 2008-12-09 16:43:25
by wza on 2008-08-19 10:29:21
by סיגריה אלקטרונית on 2009-05-27 13:48:28
by Daniel on 2009-04-22 23:24:36
by גנילה מעישון on 2009-06-07 19:14:43
by גמילה מעישון on 2009-06-07 19:15:11
by Bundles PHP per TextMate | a[]b[]c[]d[]e[] on 2009-03-04 16:25:11
by Johaana on 2009-04-16 09:18:33
by Stefan on 2009-06-22 08:51:52
by Doug Gough on 2009-08-11 04:33:43
by Matthias on 2009-07-29 15:22:08
by py on 2009-09-13 12:07:45
by Montana Flynn on 2009-11-12 22:38:44
by סיגריה אלקטרונית on 2009-12-27 21:10:31
by Jeff on 2010-01-02 05:09:50
by Daniel on 2010-01-04 17:36:54
by vlado varbanov on 2010-04-07 09:45:07
by Josh on 2010-07-10 13:35:08
by Leo Balter on 2010-04-17 14:15:18
by Miroslav Masat on 2010-05-23 06:34:28
by Jason W on 2010-05-27 06:26:40
by Craig Fairhurst on 2010-08-16 07:55:33
by Tim Mackey on 2010-09-17 15:53:26
by Noor on 2010-09-02 17:34:23
by ashorlivs on 2011-03-14 22:50:35
by fromrussia on 2011-05-04 14:35:15
by steve on 2011-07-28 15:52:55
by Shillo on 2011-08-02 03:53:31
by craig on 2011-06-26 14:28:21
by Bill on 2011-07-21 06:25:13
by Oscar on 2011-06-22 23:41:45
by Philipp Berner on 2011-07-27 20:23:27
by Richard on 2012-09-26 10:07:43
by Hugo Campos on 2012-09-10 18:00:52