JuliaEditorSupport/julia-emacs@d360ad5285 -> JuliaEditorSupport/julia-emacs@2aca8cf585 ProofGeneral/PG@3a99da2755 -> ProofGeneral/PG@b30d65de80 abo-abo/org-download@19e166f0a8 -> abo-abo/org-download@c8be261178 agda/agda@4f82f9b90a -> agda/agda@819993172d ananthakumaran/tide@b38dfc3f8f -> ananthakumaran/tide@6a35fe355f babashka/neil@6728367eff -> babashka/neil@78ffab1868 beancount/beancount-mode@7b437abcf0 -> beancount/beancount-mode@452621fa1f cdominik/cdlatex@33770dec73 -> cdominik/cdlatex@fac070f016 clojure-emacs/cider@8fdb53e8be -> clojure-emacs/cider@c228dec27d davazp/graphql-mode@ef4aecaead -> davazp/graphql-mode@c3baca9280 diml/utop@384b3098c8 -> diml/utop@b490baca21 emacs-geiser/guile@5a856c2982 -> emacs-geiser/guile@a0f111f8de emacs-geiser/mit@4e90e9ae81 -> emacs-geiser/mit@ddd2ba733e emacs-jupyter/jupyter@f97f4b5d8c -> emacs-jupyter/jupyter@e966c5d3d6 emacs-lsp/lsp-dart@9ffbafb7dc -> emacs-lsp/lsp-dart@7e3d342941 emacs-lsp/lsp-haskell@ba49fa9822 -> emacs-lsp/lsp-haskell@6981f8d122 emacs-lsp/lsp-metals@0dc938be11 -> emacs-lsp/lsp-metals@b5139c9593 emacs-lsp/lsp-pyright@0c0d72aedd -> emacs-lsp/lsp-pyright@dd54b3ae7c emacs-php/composer.el@791a7104be -> emacs-php/composer.el@6c7e19256f emacs-php/php-mode@59814bd80c -> emacs-php/php-mode@31f702ee2d emacs-rustic/rustic@d765680373 -> emacs-rustic/rustic@9fdf5c76b2 emacs-straight/auctex@08881d08ce -> emacs-straight/auctex@0de9730957 emacs-typescript/typescript.el@fc3a4f3b27 -> emacs-typescript/typescript.el@dd10f702d4 emacsmirror/org-contrib@ccd4212866 -> emacsmirror/org-contrib@f22bdd6a58 emacsmirror/paredit@037b9b8acb -> emacsmirror/paredit@af075775af emacsorphanage/dart-mode@44beb628e5 -> emacsorphanage/dart-mode@02e919c1cf emacsorphanage/macrostep@4939d88779 -> emacsorphanage/macrostep@419873665f erlang/otp@c66bf53cde -> erlang/otp@094260aba7 flatwhatson/scheme-mode@51e586e5f1 -> flatwhatson/scheme-mode@a713b253d2 godotengine/emacs-gdscript-mode@32086df833 -> godotengine/emacs-gdscript-mode@bee7f99c6f greghendershott/racket-mode@dba66c4536 -> greghendershott/racket-mode@c5bee6895b hakimel/reveal.js@472535065c -> hakimel/reveal.js@0d02d8a303 haskell/haskell-mode@727f72a2a4 -> haskell/haskell-mode@1a285fc4c5 hniksic/emacs-htmlize@ed5e5b05fd -> hniksic/emacs-htmlize@8e3841c837 jimhourihan/glsl-mode@9b2e5f28e4 -> jimhourihan/glsl-mode@c5f2c2e7ed jrblevin/markdown-mode@6102ac5b73 -> jrblevin/markdown-mode@b8637bae07 jwiegley/emacs-async@43f97d7e68 -> jwiegley/emacs-async@af47d6f930 kaushalmodi/ox-hugo@c4156d9d38 -> kaushalmodi/ox-hugo@98421a1298 ledger/ledger-mode@a6be7a2d79 -> ledger/ledger-mode@356d8049ed necaris/conda.el@ce748a53f9 -> necaris/conda.el@05de0c8f0c non-Jedi/eglot-jl@1d9cab6823 -> non-Jedi/eglot-jl@7c968cc61f nonsequitur/inf-ruby@b234625c85 -> nonsequitur/inf-ruby@6399a36682 ocaml/dune@a7924e322e -> ocaml/dune@5ac095c7c0 ocaml/merlin@e016abfac6 -> ocaml/merlin@a36f42a5b1 org-noter/org-noter@6f292d7f1e -> org-noter/org-noter@691efc3ed4 org-roam/org-roam@0b9fcbc97b -> org-roam/org-roam@2a630476b3 purcell/flycheck-ledger@628e25ba66 -> purcell/flycheck-ledger@48bed9193c purcell/flycheck-package@75efa098cf -> purcell/flycheck-package@a52e4e95f3 purcell/less-css-mode@c7fa3d56d8 -> purcell/less-css-mode@c78b88ff9a purescript-emacs/purescript-mode@eacc61aaaf -> purescript-emacs/purescript-mode@d187b3d4bb rust-lang/rust-mode@c87f6f82bd -> rust-lang/rust-mode@542f1755d8 seagle0128/grip-mode@9adac9c989 -> seagle0128/grip-mode@d6c7e33e40 senny/rbenv.el@588b817d51 -> senny/rbenv.el@4afe1dc6bd swift-emacs/swift-mode@b06c97b909 -> swift-emacs/swift-mode@ab189d6e89 technomancy/fennel-mode@f4bd34e1c3 -> technomancy/fennel-mode@259470b297 tpapp/julia-repl@801d0fc3d8 -> tpapp/julia-repl@bb90cc1fce wbolster/emacs-python-pytest@dcdaec6fe2 -> wbolster/emacs-python-pytest@25d9801562 yoshiki/yaml-mode@7b5ce294fb -> yoshiki/yaml-mode@d91f878729 ziglang/zig-mode@f55e42536a -> ziglang/zig-mode@f0b4a48753
:lang php
Description unfold
This module adds support for PHP 5.3+ (including PHP8) to Doom Emacs.
- ctags-based code completion (
company-php
andphpctags
) - eldoc support (
ac-php
andphp-extras
) - REPL (
psysh
) - Code refactoring commands (
php-refactor-mode
) - Unit-test commands (
phpunit
) - Support for
laravel
andcomposer
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.
Maintainers
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.
Packages
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
andnpm
.
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 (Recommended)
- phpactor
- Serenata
- felixbecker (Considered unsupported)
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 bysquizlabs/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 projectphpunit-current-class
Launch all tests for the current class/fixturephpunit-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
"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?