How To Install php-mode Without Root Privelages

Karol Krizka @ October 20, 2007

Linux, Programming

I am a bit fan of the GNU/Emacs editor, and I use it for all my large scale development. One reason I like it is because of its ability to handle the formating, like automatic indentation and highlighting, of PHP files with the use of the php-mode package. However this package does not come with the default GNU/Emacs installation, so when I am using a public computer or editing the files directly on the web server, I do not get the comfort of that package. I cannot install it, because I do no have the write privileges to the default site-lisp file that contains all these packages. But luckily I can easily change the path site-lisp to another directory where I can place the needed file. I will provide step-by-step instructions on how to do this.

  1. Download the php-mode package version 1.2.0
  2. Create a new directory called site-lisp in the emacs.d directory located in your home directory. You can do that by issuing the following command:

    mkdir -p ~/.emacs.d/site-lisp

  3. Install the php-mode package that you downloaded in step 1 by moving it to this directory.

    tar -xvzf php-mode-1.2.0.tgz
    mv php-mode.el ~/.emacs.d/site-lisp

  4. Open the .emacs located in your home directory file using your favorite editor. This file contains all the definitions that are automatically loaded every time you start up emacs

    emacs ~/.emacs

  5. Insert the following lines into the .emacs file. The first will append your newly created site-lisp directory to the list of directories that contain emacs packages. The rest of the lines associate PHP files with the php-mode package, so it is automatically loaded.

    (setq load-path (cons “~/.emacs.d/site-lisp” load-path))

    (autoload ‘php-mode “php-mode” “PHP editing mode” t)
    (add-to-list ‘auto-mode-alist ‘(”\\.php\\’” . php-mode))
    (add-to-list ‘auto-mode-alist ‘(”\\.php5\\’” . php-mode))
    (add-to-list ‘auto-mode-alist ‘(”\\.php4\\’” . php-mode))
    (add-to-list ‘auto-mode-alist ‘(”\\.php3\\’” . php-mode))

Did you enjoy this post? Then why not subscribe to my RSS feed or subscribe by e-mail? Also check out the many other FREE ways to appreciate a blogger.


Related Posts

RSS feed | Trackback URI

1 Comment »

Comment by krpalospo Subscribed to comments via email
2008-07-17 08:38:28

Hi, I tried install this mode in emacs for windows but didn’t work Please you can help me the error was:

when it begin say that in the buffer

An error has occurred while loading `c:/Documents and Settings/carpovmu/Datos de programa/.emacs’:

Wrong number of arguments: cons, 4

so I don’t know what i do ???

 
Name (required)
E-mail (required - never shown publicly)
URI
Subscribe to comments via email
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line=""> in your comment.

Feed