Emacs PHP Mode

用于编辑 PHP 脚本的强大而灵活的 Emacs 主模式。「A powerful and flexible Emacs major mode for editing PHP scripts」

Github星跟蹤圖

Emacs: 30.0
lang: PHP 8.4
Build Status
GPL v3
NonGNU ELPA
melpa badge

A powerful and flexible Emacs major mode for editing PHP scripts

English   |   日本語

Please submit any bug reports or feature requests by creating issues on the GitHub page for PHP Mode.

[!NOTE]
The latest version of PHP Mode supports Emacs 30.
Please feel free to open a discussion if you have any issues upgrading to Emacs 30.

[!WARNING]
After upgrading Emacs, when you open a PHP file for the first time, you may encounter errors related to CC Mode. These errors occur because a previously byte-compiled version of PHP Mode, cached on your disk, differs from the newly installed one. Reinstalling PHP Mode should resolve the issue.

Try running M-x php-mode-debug-reinstall or M-x package-reinstall php-mode.

Installation

PHP Mode works with Emacs 27.1 or later. For details on supported versions, see Supported Version.
On Emacs 28 or later, you can install it simply by running:

M-x package-install php-mode

By adding MELPA to package-archives, you can extend Emacs with numerous packages from the web.

If you prefer not to rely on a package manager, you can install the Lisp files directly in the traditional manner. See Manual installation for our recommended method.

Configuration

Personal Settings

You can add configurations for PHP Mode in your .emacs file (~/.emacs.d/init.el):

(defun my-php-mode-init ()
  (subword-mode 1)
  (setq-local show-trailing-whitespace t)
  (setq-local ac-disable-faces '(font-lock-comment-face font-lock-string-face))
  (add-hook 'hack-local-variables-hook 'php-ide-turn-on nil t))

(with-eval-after-load 'php-mode
  (add-hook 'php-mode-hook #'my-php-mode-init)
  (custom-set-variables
   '(php-mode-coding-style 'psr2)
   '(php-mode-template-compatibility nil)
   '(php-imenu-generic-expression 'php-imenu-generic-expression-simple))

  ;; If you find phpcs to be bothersome, you can disable it.
  (when (require 'flycheck nil)
    (add-to-list 'flycheck-disabled-checkers 'php-phpmd)
    (add-to-list 'flycheck-disabled-checkers 'php-phpcs)))

Project Setting

You can add project-specific settings by creating a .dir-locals.el or .dir-locals-2.el file in the project's root directory. It is recommended not to put these files under version control, as they depend on the packages installed on each user's Emacs.

((nil
  (php-project-root . git)
  (php-project-coding-style . psr2)))

Reporting Bugs

When reporting a bug, please run M-x php-mode-debug and include its output in your bug report. This helps us reproduce any issues you may be experiencing.

How to Contribute

Please see CONTRIBUTING.md.

PHP Mode is licensed under GNU General Public License Version 3 (GPLv3).

This project originated in php-mode.el written by Turadg Aleahmad in 1999. In 2013 Daniel Hackney began rewriting parts of PHP Mode in terms of Emacs' built-in CC Mode. Other contributors are listed in Authors and Contributors.

This project was maintained by Eric James Michael Ritz until 2017. Currently, the Friends of Emacs-PHP Development community inherits PHP Mode.

Copyright (C) 2022  Friends of Emacs-PHP development
Copyright (C) 1999, 2000, 2001, 2003, 2004 Turadg Aleahmad
              2008 Aaron S. Hawley
              2011, 2012, 2013, 2014, 2015, 2016, 2017 Eric James Michael Ritz

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.

主要指標

概覽
名稱與所有者emacs-php/php-mode
主編程語言Emacs Lisp
編程語言Makefile (語言數: 5)
平台
許可證GNU General Public License v3.0
所有者活动
創建於2011-07-25 23:41:33
推送於2025-04-23 00:20:13
最后一次提交2025-04-22 17:20:13
發布數48
最新版本名稱v1.27.0 (發布於 )
第一版名稱v1.5.1 (發布於 2011-07-31 19:48:58)
用户参与
星數596
關注者數47
派生數119
提交數1.7k
已啟用問題?
問題數324
打開的問題數58
拉請求數344
打開的拉請求數4
關閉的拉請求數124
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?