background image
HomeRecent PostsDrupalSearchTagsRSSContactAboutAccount
Eric.London's picture

Sometimes I am forced to edit PHP files outside Eclipse. Here's a quick guide to make your text editor (in this case, Emacs) a little more user friendly by enabled php-mode and syntax highlighting.

First, download php-mode and stick it in your ~/.emacs.d folder:

cd ~/.emacs.d
wget http://php-mode.svn.sourceforge.net/svnroot/php-mode/tags/php-mode-1.4.0/php-mode.el

Next, paste the following code into your ~/.emacs file. This will enable php-mode and syntax highlighting. As you can see, I also added a default file extension for .module files.

(global-font-lock-mode 1)

(require 'php-mode)
(setq auto-mode-alist
  (append '(("\\.php$" . php-mode)
            ("\\.module$" . php-mode))
              auto-mode-alist))

Now, when you open .php or .module files, your code will be syntax highlighted and emacs will be tailored to editing PHP code. Screen shot:

Syndicate content