Skip to content

Manual installation

USAMI Kenta edited this page Nov 18, 2023 · 3 revisions

Please git clone this project or download and unarchive tar or zip file from php-mode releases.

Requirements

Note

You can choose one of the following A, B, C installation methods.

A: (load php-mode-autoloads.el) (RECOMMENDED)

This is an initialization method that achieves the same performance and ease of use as using a package manager.

By moving the downloaded file to the extracted path of the current directory and executing the make command, byte compilation and php-mode-autoloads.el is generated. Just load the file from init.el and you are ready to use.

;; Put follow code into init.el
(when (file-directory-p "~/path/to/php-mode")
  (load "~/path/to/php-mode/php-mode-autoloads.el"))

;; Any code below is *unnecessary*
;; (require 'php-mode)
;; (add-to-list 'load-path (expand-file-name "~/path/to/php-mode"))
;; (add-to-list 'auto-mode-alist '("\\.php\\'" . php-mode))

B: (autoload 'php-mode)

This is for advanced users who want to reduce the slight increase in reading when Emacs starts.

Also in this case, it is recommended to byte compile with make.

;; Put follow code into init.el
(autoload 'php-mode (expand-file-name "~/path/to/php-mode/php-mode") "\
Major mode for editing PHP code.

\\{php-mode-map}

\(fn)" t nil)

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

;; Any code below is *unnecessary*
;; (add-to-list 'load-path (expand-file-name "~/path/to/php-mode"))
;; (require 'php-mode)

C: (require 'php-mode) (NOT RECOMMENDED)

Load php-mode synchronously from a specific path. It will load 10 times the size of the code compared to method A, and how much the startup time will depend on the performance of your machine's CPU and file system.

(require 'php-mode "~/path/to/php-mode/php-mode")
(add-to-list 'load-path (expand-file-name "~/path/to/php-mode"))