1# PHP
2
3PHP support is available through the [PHP extension](https://github.com/zed-extensions/php).
4
5- Tree-sitter: https://github.com/tree-sitter/tree-sitter-php
6- Language Servers:
7 - [phpactor](https://github.com/phpactor/phpactor)
8 - [intelephense](https://github.com/bmewburn/vscode-intelephense/)
9
10## Choosing a language server
11
12The PHP extension offers both `phpactor` and `intelephense` language server support.
13
14`phpactor` is enabled by default.
15
16## Phpactor
17
18The Zed PHP Extension can install `phpactor` automatically but requires `php` to be installed and available in your path:
19
20```sh
21# brew install php # macOS
22# sudo apt-get install php # Debian/Ubuntu
23# yum install php # CentOS/RHEL
24# pacman -S php # Arch Linux
25which php
26```
27
28## Intelephense
29
30[Intelephense](https://intelephense.com/) is a [proprietary](https://github.com/bmewburn/vscode-intelephense/blob/master/LICENSE.txt#L29) language server for PHP operating under a freemium model. Certain features require purchase of a [premium license](https://intelephense.com/).
31
32To switch to `intelephense`, add the following to your `settings.json`:
33
34```json [settings]
35{
36 "languages": {
37 "PHP": {
38 "language_servers": ["intelephense", "!phpactor", "..."]
39 }
40 }
41}
42```
43
44To use the premium features, you can place your [licence.txt file](https://intelephense.com/faq.html) at `~/intelephense/licence.txt` inside your home directory. Alternatively, you can pass the licence key or a path to a file containing the licence key as an initialization option for the `intelephense` language server. To do this, add the following to your `settings.json`:
45
46```json [settings]
47{
48 "lsp": {
49 "intelephense": {
50 "initialization_options": {
51 "licenceKey": "/path/to/licence.txt"
52 }
53 }
54 }
55}
56```
57
58## PHPDoc
59
60Zed supports syntax highlighting for PHPDoc comments.
61
62- Tree-sitter: [claytonrcarter/tree-sitter-phpdoc](https://github.com/claytonrcarter/tree-sitter-phpdoc)