doom-emacs/modules/lang/php
Henrik Lissner 99344edbe7
bump: :lang
Andersbakken/rtags@ee1ab7b9a6 -> Andersbakken/rtags@05117a9a29
FStarLang/fstar-mode.el@ab0697b947 -> FStarLang/fstar-mode.el@7d353de892
Fanael/edit-indirect@f80f63822f -> Fanael/edit-indirect@82a28d8a85
ProofGeneral/PG@8416875696 -> ProofGeneral/PG@a38857a6a0
Sarcasm/irony-mode@870d1576fb -> Sarcasm/irony-mode@40e0ce19eb
aaronjensen/flycheck-credo@e88f11ead5 -> aaronjensen/flycheck-credo@e285bd042a
agda/agda@bb7603d197 -> agda/agda@fbf9d159c3
amake/flutter.el@edd3f5eb3f -> amake/flutter.el@004c91e070
ananthakumaran/exunit.el@e0a8c2b81f -> ananthakumaran/exunit.el@e008c89e01
ananthakumaran/tide@29475d9eee -> ananthakumaran/tide@b38dfc3f8f
arthurnn/minitest-emacs@ddd152c990 -> arthurnn/minitest-emacs@5999c45c04
babashka/neil@40993873bb -> babashka/neil@a1db63d420
beancount/beancount-mode@0f1e33067e -> beancount/beancount-mode@546163fd2c
borkdude/flycheck-clj-kondo@ff7bed2315 -> borkdude/flycheck-clj-kondo@9089ade9e0
cdominik/cdlatex@ac024ce293 -> cdominik/cdlatex@33770dec73
clojure-emacs/cider@120fd885d3 -> clojure-emacs/cider@aa26d62ac5
clojure-emacs/clj-refactor.el@0a2a6cbc2e -> clojure-emacs/clj-refactor.el@fa3efe18e7
clojure-emacs/clojure-mode@25d713a67d -> clojure-emacs/clojure-mode@222fdafa2a
clojure-emacs/parseclj@74ff7d63fe -> clojure-emacs/parseclj@6af22372e0
clojure-emacs/parseedn@c8f07926a6 -> clojure-emacs/parseedn@3407e4530a
crystal-lang-tools/emacs-crystal-mode@9bfb9f0f56 -> crystal-lang-tools/emacs-crystal-mode@ea89b108fa
davazp/graphql-mode@1437b79006 -> davazp/graphql-mode@49a391b529
dgutov/robe@912ae2ba1f -> dgutov/robe@4ecd868da9
dominikh/go-mode.el@166dfb1e09 -> dominikh/go-mode.el@8dce1e3ba1
elixir-editors/emacs-elixir@7641373f05 -> elixir-editors/emacs-elixir@00d6580a04
emacs-geiser/geiser@49d12a1448 -> emacs-geiser/geiser@bb77719c25
emacs-geiser/guile@ee33af6b4e -> emacs-geiser/guile@6e0811c75d
emacs-lsp/emacs-ccls@dd33da8ed7 -> emacs-lsp/emacs-ccls@9b4a47e041
emacs-lsp/lsp-dart@3db9f93c83 -> emacs-lsp/lsp-dart@e7ee6afc2e
emacs-lsp/lsp-java@449673da72 -> emacs-lsp/lsp-java@c962a3b3ac
emacs-php/composer.el@5af1707fef -> emacs-php/composer.el@91945f1bdb
emacs-php/php-mode@fb11df8268 -> emacs-php/php-mode@a0bcafbe30
emacs-php/phpactor.el@9440005814 -> emacs-php/phpactor.el@8733fef84b
emacs-php/psysh.el@796b26a5cd -> emacs-php/psysh.el@c7dde979d9
emacs-straight/adaptive-wrap@0d5b4a07de -> emacs-straight/adaptive-wrap@70005d2012
emacs-straight/auctex@3929d5408b -> emacs-straight/auctex@86b2397abd
emacs-straight/csv-mode@d190a479b4 -> emacs-straight/csv-mode@81c1a9febd
emacs-straight/rainbow-mode@8e96388fb4 -> emacs-straight/rainbow-mode@70ed10d410
emacs-straight/sml-mode@5426ff4738 -> emacs-straight/sml-mode@e5354371f3
emacsmirror/cmake-mode@f9c7a21254 -> emacsmirror/cmake-mode@b08b5d9045
emacsorphanage/dart-mode@9c846769ab -> emacsorphanage/dart-mode@dffc0209a1
erlang/otp@be7109f43b -> erlang/otp@0ca7e064f5
factor/factor@76ac65649d -> factor/factor@23fcfc7075
flycheck/flycheck-cask@4b2ede6362 -> flycheck/flycheck-cask@0eeec5197e
fxbois/web-mode@57856ba64b -> fxbois/web-mode@82847071ce
gcv/julia-snail@18b891b456 -> gcv/julia-snail@d36653bb93
gdkrmr/lsp-julia@c584f79c7f -> gdkrmr/lsp-julia@c869b2f6c0
godotengine/emacs-gdscript-mode@d392e8aa7e -> godotengine/emacs-gdscript-mode@8a28276daa
greghendershott/racket-mode@947d9806ee -> greghendershott/racket-mode@d3ab936af1
haskell/haskell-mode@79eaf444a7 -> haskell/haskell-mode@43b4036bf0
hhvm/hack-mode@26f06ffe82 -> hhvm/hack-mode@278e4cc403
hvesalai/emacs-scala-mode@5d7cf21c37 -> hvesalai/emacs-scala-mode@4c6d636b86
idris-hackers/idris-mode@c96f45d1b8 -> idris-hackers/idris-mode@37c6b81990
immerrr/lua-mode@7eb8eaa420 -> immerrr/lua-mode@d074e4134b
iyefrat/evil-tex@3e0a26b91a -> iyefrat/evil-tex@2a3177c818
jrblevin/markdown-mode@b1a862f016 -> jrblevin/markdown-mode@e096bb97a9
json-emacs/json-mode@eedb456003 -> json-emacs/json-mode@bfd1557aaa
jwiegley/emacs-async@71cc50f27f -> jwiegley/emacs-async@d040f72cb0
ledger/ledger-mode@4b32f70173 -> ledger/ledger-mode@11e748d483
ljos/jq-mode@071c1c29ba -> ljos/jq-mode@37028e1200
nex3/haml-mode@fe83c65c1f -> nex3/haml-mode@a64d58df8f
nlamirault/phpunit.el@4a36906344 -> nlamirault/phpunit.el@650a50898d
nonsequitur/inf-ruby@03475ac1cc -> nonsequitur/inf-ruby@dac615c7fd
ocaml-ppx/ocamlformat@7db948a894 -> ocaml-ppx/ocamlformat@b8b0956690
ocaml/dune@360b000271 -> ocaml/dune@64d19876ad
pashky/restclient.el@0ba72816f9 -> pashky/restclient.el@e2a2b13482
psibi/dhall-mode@c77f1c1e75 -> psibi/dhall-mode@87ab69fe76
purescript-emacs/emacs-psci@9bb6a32532 -> purescript-emacs/emacs-psci@ef31045295
purescript-emacs/psc-ide-emacs@ce97d71945 -> purescript-emacs/psc-ide-emacs@4e614df553
s-kostyaev/go-gen-test@f84f4177af -> s-kostyaev/go-gen-test@af00a9abba
seagle0128/grip-mode@5809fb62f6 -> seagle0128/grip-mode@e145adb225
senny/rbenv.el@2ea1a5bdc1 -> senny/rbenv.el@588b817d51
technomancy/fennel-mode@8f721285e1 -> technomancy/fennel-mode@5965c8fc69
tpapp/julia-repl@9503ef7110 -> tpapp/julia-repl@4947319bc9
weijiangan/flycheck-golangci-lint@8e446c6831 -> weijiangan/flycheck-golangci-lint@9def093e41
wwwjfy/emacs-fish@6869efbc05 -> wwwjfy/emacs-fish@2526b1803b
yoshiki/yaml-mode@3fcb36d603 -> yoshiki/yaml-mode@5b58248ab2

Close: #7648
2024-05-21 17:16:40 +02:00
..
autoload.el feat(php): replace php-boris with psysh (#5967) 2022-01-10 02:24:21 +01:00
config.el
doctor.el feat(php): doctor: rudimentary php & composer checks 2024-05-21 17:15:54 +02:00
packages.el bump: :lang 2024-05-21 17:16:40 +02:00
README.org docs(*): replace all-the-icons with nerd-icons 2024-05-21 17:16:13 +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)
  • 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 and intelephense).
+tree-sitter
Leverages tree-sitter for better syntax highlighting and structural text editing. Requires doom-module::tools tree-sitter.

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)
  • php-cs-fixer and @prettier/plugin-php (for code formatting)
  • phpactor (for LSP if intelephense isn't desired)
composer global require \
    psy/psysh \
    phpunit/phpunit \
    techlivezheng/phpctags \
    friendsofphp/php-cs-fixer \
    phpactor/phpactor

# Needed by php-cs-fixer, otherwise you'll get "Couldn't resolve parser
# 'php'" errors
npm install -g @prettier/plugin-php

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?