How To Install php-mode Without Root Privelages
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.
- Download the php-mode package version 1.2.0
- 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
- 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
- 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
- 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))