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.elNext, 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:











parentheses typo
The ~.emacs code should be this:
(global-font-lock-mode 1)
(require 'php-mode)
(setq auto-mode-alist
(append '(("\\.php$" . php-mode)
("\\.module$" . php-mode))
auto-mode-alist)))
Note the additional trailing parentheses at the very end.
Correction
Regarding the anonymous comment: pff.. there is no third parenthesis, what are you talking about?! grrr -_-'
On the other hand there is one correction worth being mentionned, in some cases, you might need to add this before invoking the php mode:
(add-to-list 'load-path "~/.emacs.d")Thanks,
Chess.
Package for Ubuntu
$ sudo apt-get install php-mode
works on Ubuntu. (If you're a noob, like me.)
thanks
No love for Centos :(
[Eric@VirtualBox-Centos ~]$ yum search php-modeLoaded plugins: fastestmirror
Warning: No matches found for: php-mode
No Matches found
Ubuntu Lucid
This works now:
aptitude install emacs-snapshot emacs-goodies-el php-elisp ruby-elisp python-elisp
The package is called php-elisp in ubuntu now...