Next: , Previous: Introduction, Up: Top


2 Installation

PHP mode can be installed like any Emacs Lisp library.

Download a source archive of the file. It is available from PHP mode's Web site.

http://php-mode.sourceforge.net/

Download either the file php-mode-1.5.0.tar.gz or php-mode-1.5.0.zip. Both source files have a respective GnuPG1 signature file with a .sig file name extension.

To verify the source archive you need the key of the maintainer. The public key can be downloaded from the Web site and imported, or imported from a key server.

     $ gpg --recv-keys 8E372922
     gpg: requesting key 8E372922 from hkp server keys.gnupg.net
     gpg: key 8E372922: public key
     "Aaron S. Hawley (SourceForge) <ashawley@users.sourceforge.net>"
     imported

The public key can also be imported from a file.

     $ gpg --import ashawley-sf-pubkey.asc
     gpg: key 8E372922: public key
     "Aaron S. Hawley (SourceForge) <ashawley@users.sourceforge.net>"
     imported
     gpg: Total number processed: 1
     gpg:               imported: 1

Assign the trust for the maintainer key.

     $ gpg --edit-key 8E372922
     Command> trust
     pub  1024D/8E372922  created: 2008-01-25  expires: 2010-01-01  usage: SC
                          trust: unknown       validity: unknown
     sub  2048g/A4B44512  created: 2008-01-25  expires: 2010-01-01  usage: E
     [ unknown] (1). Aaron S. Hawley (SourceForge)
                     <ashawley@users.sourceforge.net>
     
     Please decide how far you trust this user to correctly
     verify other users' keys (by looking at passports, checking
     fingerprints from different sources, etc.)
     
       1 = I don't know or won't say
       2 = I do NOT trust
       3 = I trust marginally
       4 = I trust fully
       5 = I trust ultimately
       m = back to the main menu
     
     Your decision? 1
     
     pub  1024D/8E372922  created: 2008-01-25  expires: 2010-01-01  usage: SC
                          trust: undefined     validity: unknown
     sub  2048g/A4B44512  created: 2008-01-25  expires: 2010-01-01  usage: E
     [ unknown] (1). Aaron S. Hawley (SourceForge)
                     <ashawley@users.sourceforge.net>
     Command> quit

Verify a source package by using the GPG verify command on the signature file with the source file located in the same directory.

     $ gpg --verify php-mode-1.4.0.tar.gz.sig
     gpg: Signature made Fri 25 Jan 2008 01:30:24 PM EST
     gpg: using DSA key ID 8E372922
     gpg: Good signature from
     "Aaron S. Hawley (SourceForge) <ashawley@users.sourceforge.net>"
     Primary key fingerprint: B425 30C2 4F72 D4F1 FD01
                              D07D 7087 6760 8E37 2922

After the source package is verified, unpack the source archive.

     $ tar zxf php php-mode-1.5.0.tar.gz

The files are extracted to the directory php-mode-1.5.0. Run make in the directory to build all the formats of the documentation – Info, HTML, PostScript and PDF. Read the notes in the Makefile to learn how to run make to compile the manual into a single particular format.

If you have a local directory where Emacs Lisp libraries are stored, for example ~/elisp, then put the following in your .emacs file if you haven't already

     (add-to-list 'load-path "~/elisp")

Then, put the file php-model.el into your Emacs load-path, ~/elisp, and add php-mode to your .emacs file.

     (load "php-mode")

From inside Emacs, run M-x customize-variable RET php-file-patterns RET. This variable instructs Emacs what file names should be opened in PHP mode. If the defaults are fine, then click or hit RET on ‘Save for Future Sessions’.

Alternatively, put these lines in your .emacs file.

     (add-to-list 'auto-mode-alist
     	     '("\\.php[34]?\\'\\|\\.phtml\\'" . php-mode))

If you work on projects, like Drupal, that use other extension for PHP source file, you may need to add this to your .emacs.

     (add-to-list 'auto-mode-alist '("\\.module\\'" . php-mode))
     (add-to-list 'auto-mode-alist '("\\.inc\\'" . php-mode))

Footnotes

[1] More information on GPG and OpenPGP at http://www.gnupg.org/