Skip to main content

PHP

info

You can enable the extra with the :LazyExtras command. Plugins marked as optional will only be configured if they are installed.

Alternatively, you can add it to your lazy.nvim imports
lua/config/lazy.lua
require("lazy").setup({
spec = {
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
{ import = "lazyvim.plugins.extras.lang.php" },
{ import = "plugins" },
},
})

Options

Additional options for this extra can be configured in your lua/config/options.lua file:

lua/config/options.lua
-- LSP Server to use for PHP.
-- Set to "intelephense" to use intelephense instead of phpactor.
vim.g.lazyvim_php_lsp = "intelephense"

Below you can find a list of included plugins and their default settings.

caution

You don't need to copy the default settings to your config. They are only shown here for reference.

nvim-treesitter

opts = { ensure_installed = { "php" } }

nvim-lspconfig

opts = {
servers = {
phpactor = {
enabled = lsp == "phpactor",
},
intelephense = {
enabled = lsp == "intelephense",
},
[lsp] = {
enabled = true,
},
},
}

mason.nvim

opts = {
ensure_installed = {
"phpcs",
"php-cs-fixer",
},
}

nvim-dap (optional)

opts = function()
local dap = require("dap")
local path = require("mason-registry").get_package("php-debug-adapter"):get_install_path()
dap.adapters.php = {
type = "executable",
command = "node",
args = { path .. "/extension/out/phpDebug.js" },
}
end

none-ls.nvim (optional)

opts = function(_, opts)
local nls = require("null-ls")
opts.sources = opts.sources or {}
table.insert(opts.sources, nls.builtins.formatting.phpcsfixer)
table.insert(opts.sources, nls.builtins.diagnostics.phpcs)
end

nvim-lint (optional)

opts = {
linters_by_ft = {
php = { "phpcs" },
},
}

conform.nvim (optional)

opts = {
formatters_by_ft = {
php = { "php_cs_fixer" },
},
}