Files
doomemacs/modules/lang/php
Henrik Lissner 8d7bf44c72 bump: :lang
FStarLang/fstar-mode.el@3bbfe93abd -> FStarLang/fstar-mode.el@537c31983f
Fuco1/sphinx-mode@77ca51adf9 -> Fuco1/sphinx-mode@038a9195b0
OCamlPro/ocp-indent@f38578c25d -> OCamlPro/ocp-indent@1213857683
ProofGeneral/PG@af2e7b9a4e -> ProofGeneral/PG@fbb2878e49
ShuguangSun/ess-view-data@dd6a85935b -> ShuguangSun/ess-view-data@5ec1c7206f
abicky/nodejs-repl.el@130d49b073 -> abicky/nodejs-repl.el@c232b4964b
agda/agda@900bdaa335 -> agda/agda@5e31b2534d
ananthakumaran/exunit.el@8de56e3fd5 -> ananthakumaran/exunit.el@9a7cfc3d78
bricka/emacs-kotlin-ts-mode@a25d56ceca -> bricka/emacs-kotlin-ts-mode@051c9ef534
clojure-emacs/cider@12f10a6f4b -> clojure-emacs/cider@389833f85a
clojure-emacs/clj-refactor.el@dc1bbc8cda -> clojure-emacs/clj-refactor.el@362cb46bf8
clojure-emacs/clojure-mode@b766094aea -> clojure-emacs/clojure-mode@28dc02114a
clojure-emacs/clojure-ts-mode@da56a6938f -> clojure-emacs/clojure-ts-mode@32490c80fa
cpitclaudel/company-coq@5affe7a96a -> cpitclaudel/company-coq@78ed04ce39
diml/utop@3322adaa52 -> diml/utop@33201e6076
emacs-ess/ESS@d19efaae12 -> emacs-ess/ESS@8369d574f1
emacs-geiser/chicken@5f2c1bb446 -> emacs-geiser/chicken@8342bad8ce
emacs-geiser/geiser@c1c27072a4 -> emacs-geiser/geiser@c8b862f00e
emacs-lsp/emacs-ccls@5636ee6c50 -> emacs-lsp/emacs-ccls@34251b799e
emacs-lsp/lsp-haskell@081d5115ce -> emacs-lsp/lsp-haskell@aa9b5bce35
emacs-lsp/lsp-java@21c89243ad -> emacs-lsp/lsp-java@9230a0007c
emacs-lsp/lsp-pyright@73377169be -> emacs-lsp/lsp-pyright@0e59c00c7f
emacs-lsp/lsp-sourcekit@1fb230109e -> emacs-lsp/lsp-sourcekit@30918cd1ae
emacs-php/php-mode@462b62248f -> emacs-php/php-mode@40b8abed30
emacs-rustic/rustic@29f912c750 -> emacs-rustic/rustic@2b4ac5de3b
emacs-straight/auctex@f58a2b972b -> emacs-straight/auctex@a2809e4d70
emacs-straight/org-mode@4e6d38d1a6 -> emacs-straight/org-mode@8b15a0d0b4
emacsorphanage/dart-mode@f82ff05230 -> emacsorphanage/dart-mode@edb45cb709
emacsorphanage/htmlize@8e3841c837 -> emacsorphanage/htmlize@c9a8196a59
emacsorphanage/restclient@bba663590f -> emacsorphanage/restclient@ad97f666b6
erlang/otp@b9d3ec017d -> erlang/otp@2a970bf725
fosskers/sly-overlay@d629450590 -> fosskers/sly-overlay@345b554ad0
fsharp/emacs-fsharp-mode@8d08f05788 -> fsharp/emacs-fsharp-mode@91abae13e8
fuxialexander/org-pdftools@5613b7ae56 -> fuxialexander/org-pdftools@2b3357828a
fxbois/web-mode@be2d59c8fa -> fxbois/web-mode@1eb0abb1a9
godotengine/emacs-gdscript-mode@5136be407a -> godotengine/emacs-gdscript-mode@a0d25b46d8
greghendershott/racket-mode@c4cc7c160b -> greghendershott/racket-mode@172b7d4c5a
hakimel/reveal.js@eb95b14531 -> hakimel/reveal.js@4cf184924d
haskell/haskell-mode@e9c3567393 -> haskell/haskell-mode@e5d32021ea
idris-hackers/idris-mode@ccf32ed0b5 -> idris-hackers/idris-mode@da5c22f436
jart/disaster@8b44591322 -> jart/disaster@0299c129d4
joaotavora/sly@ce17a568ef -> joaotavora/sly@63131ef965
jschaf/powershell.el@9efa1b4d0a -> jschaf/powershell.el@99e0e73082
jwiegley/nix-update-el@77022ccd91 -> jwiegley/nix-update-el@d67f4f7ba8
kaushalmodi/ox-hugo@e3365cb4e6 -> kaushalmodi/ox-hugo@a907ea9514
ledger/ledger-mode@d9b6648201 -> ledger/ledger-mode@e9bb645e8f
magit/orgit-forge@050590fbc7 -> magit/orgit-forge@5a0dbe2601
magit/orgit@224350397d -> magit/orgit@8493c24808
minad/org-modern@1723689710 -> minad/org-modern@d5e1f5af65
necaris/conda.el@05de0c8f0c -> necaris/conda.el@8a1a934a2d
nex3/haml-mode@a64d58df8f -> nex3/haml-mode@3bb4a96535
nix-community/nix-ts-mode@62ce3a2dc3 -> nix-community/nix-ts-mode@e68ef36312
ocaml/dune@422986440e -> ocaml/dune@28b7e8f3b2
ocaml/merlin@e4c66857ad -> ocaml/merlin@8b88b89ee7
oer/org-re-reveal@da7e1feba9 -> oer/org-re-reveal@4eb0f71474
org-noter/org-noter@a28f61238a -> org-noter/org-noter@aafa08a49c
org-roam/org-roam@c172951345 -> org-roam/org-roam@89dfaef38b
polymode/polymode@74ba75d4bc -> polymode/polymode@25ba9463a4
pope/ob-go@2067ed55f4 -> pope/ob-go@c6c7c811fb
ppareit/graphviz-dot-mode@8ff793b137 -> ppareit/graphviz-dot-mode@2c7ba85d19
purescript-emacs/psc-ide-emacs@4e614df553 -> purescript-emacs/psc-ide-emacs@c64b05d901
purescript-emacs/purescript-mode@8c4736759a -> purescript-emacs/purescript-mode@61732e23bd
pythonic-emacs/pyenv-mode@ba1a8c7bd7 -> pythonic-emacs/pyenv-mode@364bddb8f0
rust-lang/rust-mode@25d91cff28 -> rust-lang/rust-mode@9915b3a585
salmanebah/opencl-mode@204d5d9e0f -> salmanebah/opencl-mode@6464abf969
shoshin/minitest-emacs@5999c45c04 -> shoshin/minitest-emacs@d278e94fb1
skuro/plantuml-mode@ea45a13707 -> skuro/plantuml-mode@348e83ff19
slim-template/emacs-slim@8c92169817 -> slim-template/emacs-slim@0b1b380329
sogaiu/janet-ts-mode@ac684edf57 -> sogaiu/janet-ts-mode@0e4d04d648
swift-emacs/swift-mode@e30b9d46e0 -> swift-emacs/swift-mode@fc7df7bd90
szermatt/emacs-bash-completion@d0637428fd -> szermatt/emacs-bash-completion@762f28fefb
technomancy/fennel-mode@df8e83d6e2 -> technomancy/fennel-mode@0d638f6133
tpapp/julia-repl@317d560218 -> tpapp/julia-repl@681efc14a7
wbolster/emacs-python-pytest@25d9801562 -> wbolster/emacs-python-pytest@ed2ecee09d
ziglang/zig-mode@c46d024733 -> ziglang/zig-mode@dab3c37c2d
zweifisch/ob-elixir@8990a8178b -> zweifisch/ob-elixir@8e5d2f3c7a
2025-09-02 16:16:03 +02:00
..
2024-09-14 20:47:39 -04:00
2025-09-02 16:16:03 +02:00
2025-05-15 18:19:32 +02:00

:lang php

Description   unfold

This module adds support for PHP 5.3+ (including PHP8) to Doom Emacs.

  • ctags-based code completion (company-php and phpctags)
  • eldoc support (ac-php and php-extras)
  • REPL (psysh)
  • Code refactoring commands (php-refactor-mode)
  • Unit-test commands (phpunit)
  • Support for laravel and composer projects (with project-specific snippets)
  • LSP support (via the doom-module:+lsp flag)
  • File templates
  • Snippets

󰟶 PHP was the first programming language I got paid to code in, back in the Cretaceous period (2003). My sincerest apologies go out to all the programmers who inherited my earliest PHP work. I know you're out there, writhing in your straitjackets.

Module flags

+hack
Add support for the Hack dialect of PHP by Facebook.
+lsp
Enable LSP support for php-mode. Requires doom-module::tools lsp and a langserver (supports phpactor, intelephense, serenata, php-language-server).
+tree-sitter
Leverages tree-sitter for better syntax highlighting and structural text editing. Requires doom-module::tools tree-sitter and Emacs 30.1+.

Hacks

No hacks documented for this module.

TODO Changelog

This module does not have a changelog yet.

Installation

Enable this module in your doom! block.

This module requires php (5.3+) and composer.

If doom-module:+lsp is enabled, you'll also need one of these LSP servers:

  • Phpactor requires php 7.3+.
  • Intelephense requires node and npm.

PHP

MacOS

PHP 5.5 comes prepackaged with newer versions of MacOS. These instructions are provided for reference:

brew tap homebrew/homebrew-php
brew install php@8.0  # or php53, php54, php55
brew install composer

# If you use intelephense:
brew install node
brew install npm

Arch Linux

sudo pacman --needed --noconfirm -S php composer  # or php53, php54, php55

# If you use intelephense:
sudo pacman -S nodejs npm

openSUSE

sudo zypper install php-composer

# If you use intelephense:
sudo zypper install nodejs npm

Debian

sudo apt-get install php php-common

# If you use intelephense:
sudo apt-get install nodejs npm

LSP Support

There are a number of currently supported LSP servers:

Intelephense is currently the only server that supports automatic installation, which will trigger either when you open a PHP project or manually invoke lsp-install-server through M-x.

The others have to be installed manually and added to your $PATH.

Dependencies

  • pysh (REPL)
  • phpctags (better code completion)
  • phpunit (unit test commands)
  • phpcbf, provided by squizlabs/php_codesniffer (for code formatting)
  • phpactor (for LSP if intelephense isn't desired)
composer global require \
    psy/psysh \
    phpunit/phpunit \
    techlivezheng/phpctags \
    squizlabs/php_codesniffer \
    phpactor/phpactor

You must ensure that $HOME/.composer/vendor/bin is in $PATH, so these executables are visible to Emacs:

# place this in your profile file, like ~/.bash_profile or ~/.zshenv
export PATH="~/.composer/vendor/bin:$PATH"

You may also need to regenerate your envvar file by running $ doom env on the command line.

NOTE phpactor doesn't have to be installed via composer, just has to exist in your $PATH.

NOTE Phpactor cannot be installed, globally at least, with PHP ^8.

TODO Usage

󱌣 This module's usage documentation is incomplete. Complete it?

PHPUnit

This module provides an interface to PHPUnit through a number of commands as detailed below. By default, it loads configuration from the root phpunit.xml.

  • phpunit-current-project Launch all tests for the project
  • phpunit-current-class Launch all tests for the current class/fixture
  • phpunit-current-test Launch the current test at point

If for some reason, the default phpunit.xml is in a different location (or you use the phpunit.xml.dist convention) , the path can be changed via phpunit-configuration-file

(setq phpunit-configuration-file "phpunit.xml")

Composer

This module provides several convenience methods for triggering composer commands:

Binding Function
<localleader> m c c composer
<localleader> m c i composer-install
<localleader> m c r composer-require
<localleader> m c u composer-update
<localleader> m c d composer-dump-autoload
<localleader> m c s composer-run-scripts
<localleader> m c v composer-run-vendor-bin-command
<localleader> m c o composer-find-json-file
<localleader> m c l composer-view-lock-file

These are all run via M-x too.

TODO Configuration

󱌣 This module's configuration documentation is incomplete. Complete it?

Docker Compose

A lot of projects rely on running inside docker compose (ie Laravel), and as such a minor mode has been configured to attempt to run tests inside the php-fpm (by default) container.

This mode is disabled by default, to opt-in set +php-run-tests-in-docker to t in your config. If this is done during Emacs running, you will also have to reload php-mode (i.e. through M-x php-mode)

If you wish to specify a different container, modify the +php-default-docker-container variable (ideally inside a .dir-locals.el file)

((php-mode . ((+php-default-docker-container . "php-octane"))))

Troubleshooting

Report an issue?

"I'm missing functionality on lsp-mode"

Unfortunately, intelephense currently operates under a "freemium" model, and as such requires a license for extended features. Once purchased, this can be (insecurely) added directly to your config:

(setq lsp-intelephense-licence-key "<key>")

A more recommended approach would be to utilise Emacs' own auth-sources for storing authentication info, which can also be encrypted.

Create a file in your home directory (which can optionally be encrypted, verify your auth-sources has the correct values) called ~/.authinfo:

machine * login intelephense password <key>

And add the following to your config:

(defun my-fetch-password (&rest params)
  (require 'auth-source)
  (let ((match (car (apply #'auth-source-search params))))
    (if match
        (let ((secret (plist-get match :secret)))
          (if (functionp secret)
              (funcall secret)
            secret))
      (error "Password not found for %S" params))))

(setq lsp-intelephense-licence-key (my-fetch-password :user intelephense))

Frequently asked questions

This module has no FAQs yet. Ask one?

TODO Appendix

󱌣 This module has no appendix yet. Write one?