fix(php): give PHPantom the template, configuration and settings support it has (#7827)

PHPantom has its own Blade, Twig and framework support, but Twig, YAML and XML files were never sent to it, laravel-lsp kept running alongside it, and it was never told the project is trusted. PHPantom now joins twig, yaml and xml (XML limited to *.xml, *.xlf, *.xliff), replaces laravel-lsp, gets .phpantom.toml as a root marker, and configure_phpantom sends workspaceTrusted (servers only start outside Restricted Mode) plus the excluded folders and PHP file-type extensions as its indexing filters at startup and on every configuration change. Docs updated.

Co-authored-by: AJenbo <[email protected]>
Цей коміт міститься в:
Anders JenboтаAJenbo authored and GitHub committed 2026-12-03 23:06:52 +08:00
1 джерело 1c94aeb476
коміт d4a2a84c36
13 files changed
+183 -22

No files matched your search

+27 -1
Переглянути файл
@@ -1168,12 +1168,38 @@ mod tests {
// No other language starts a PHP server.
for lang in reg.all() {
for server in lang.language_servers.iter().filter(|s| s.joins.is_some()) {
assert_eq!((server.name.as_str(), server.joins.as_deref()), ("phoxite", Some("php")), "{}", lang.id);
assert!(["phoxite", "phpantom"].contains(&server.name.as_str()), "{}: {}", lang.id, server.name);
assert_eq!(server.joins.as_deref(), Some("php"), "{}", lang.id);
}
}
assert!(php.language_servers.iter().all(|s| s.joins.is_none() && s.files.is_empty()));
}
#[test]
fn phpantom_reads_templates_and_configuration_where_it_serves_php() {
let reg = reg();
let php = reg.get(&LanguageId::new("php")).unwrap();
let of_php = php.language_servers.iter().find(|s| s.name == "phpantom").unwrap();
// It answers the Laravel strings itself.
assert_eq!(of_php.replaces, ["laravel-lsp"]);
// Only the XML it reads: an SVG would be parsed as PHP.
let xml = &["**/*.xml", "**/*.xlf", "**/*.xliff"][..];
for (language, files) in [("twig", &[][..]), ("yaml", &[][..]), ("xml", xml)] {
let cfg = reg.get(&LanguageId::new(language)).unwrap();
let phpantom = cfg.language_servers.iter().find(|s| s.name == "phpantom").unwrap();
assert_eq!(phpantom.joins.as_deref(), Some("php"), "{language}");
assert_eq!(phpantom.files, files, "{language}");
assert_eq!(
(&phpantom.command, &phpantom.args, &phpantom.root_markers),
(&of_php.command, &of_php.args, &of_php.root_markers),
"{language}"
);
}
let blade = reg.get(&LanguageId::new("blade")).unwrap();
let of_blade = blade.language_servers.iter().find(|s| s.name == "phpantom").unwrap();
assert_eq!((&of_blade.root_markers, &of_blade.replaces), (&of_php.root_markers, &of_php.replaces));
}
#[test]
fn pylsp_adds_only_rope_refactorings_to_python() {
let reg = reg();
+3
Переглянути файл
@@ -1550,6 +1550,9 @@ pub fn configure_server(cfg: &mut LanguageServerConfig, root: &Path, server_root
if name == "phoxite" {
crate::php::configure_phoxite(cfg, root, s);
}
if name == "phpantom" {
crate::php::configure_phpantom(cfg, s);
}
// Node-based servers (`#!/usr/bin/env node`) run on the selected Node.js.
if let Some(dir) = node_dir(root, s) {
+26
Переглянути файл
@@ -229,6 +229,32 @@ pub fn configure_phoxite(cfg: &mut LanguageServerConfig, root: &Path, s: &Settin
cfg.settings = Some(settings);
}
/// What PHPantom reads from the editor. It only starts in a trusted project, so it is told
/// that, and runs the project's PHPStan, PHP_CodeSniffer and formatters without asking again.
/// The excluded folders and the extensions added to PHP in Settings › File Types become its
/// `indexing` filters, which it adds to those of the project's `.phpantom.toml`. It reads the
/// PHP version from `composer.json` or `.phpantom.toml` itself.
///
/// The filters are sent at startup and, under `phpantom`, with every
/// `workspace/didChangeConfiguration`, so a change applies without a restart.
pub fn configure_phpantom(cfg: &mut LanguageServerConfig, s: &Settings) {
let extensions: Vec<String> = s
.files
.file_types
.get("php")
.into_iter()
.flat_map(|php| &php.patterns)
.filter_map(|pattern| pattern.trim().strip_prefix("*."))
.filter(|ext| !ext.is_empty() && !ext.contains(['.', '*', '?', '/', '\\']))
.map(str::to_owned)
.collect();
let indexing = json!({ "exclude": s.exclude_globs(), "extensions": extensions });
merge_init_options(cfg, json!({ "workspaceTrusted": true, "indexing": indexing.clone() }));
let mut settings = cfg.settings.take().filter(Value::is_object).unwrap_or_else(|| json!({}));
merge(&mut settings, json!({ "phpantom": { "indexing": indexing } }));
cfg.settings = Some(settings);
}
/// `vendor/bin/phpstan analyse` of `files` with a JSON report and the configuration file of
/// Settings › PHP, run from `root` with Xdebug off: in debug mode it would try to reach a
/// debugger on every run. The selected PHP runs the script itself (and is first on `PATH`, as for
+41
Переглянути файл
@@ -3338,6 +3338,47 @@ fn phoxite_gets_the_php_settings_at_startup_and_on_every_configuration_change()
assert_eq!(other.settings, None);
}
#[test]
fn phpantom_is_trusted_and_gets_the_file_filters_at_startup_and_on_every_configuration_change() {
use serde_json::json;
let tmp = tempfile::tempdir().unwrap();
let mut s = Settings::default();
s.project_structure.excluded = vec!["storage/".into()];
s.files.file_types.insert(
"php".into(),
ide_core::settings::FileTypeAssociation {
// Only the patterns that name an extension: `inc`, `module`.
patterns: vec![
"*.inc".into(),
" *.module ".into(),
"*.blade.php".into(),
"Jenkinsfile".into(),
"*.".into(),
],
..Default::default()
},
);
let mut cfg = server("phpantom");
configure_server(&mut cfg, tmp.path(), tmp.path(), &s);
let options = serde_json::to_value(&cfg.initialization_options).unwrap();
assert_eq!(options["workspaceTrusted"], json!(true));
let indexing = &options["indexing"];
assert_eq!(indexing["extensions"], json!(["inc", "module"]));
assert_eq!(indexing["exclude"], json!(s.exclude_globs()));
assert!(s.exclude_globs().contains(&"/storage".to_owned()));
// What `workspace/didChangeConfiguration` carries: PHPantom reads the `phpantom` section.
assert_eq!(cfg.settings, Some(json!({"phpantom": {"indexing": indexing}})));
// An empty list is sent too: it clears what an earlier notification set.
let mut cfg = server("phpantom");
configure_server(&mut cfg, tmp.path(), tmp.path(), &Settings::default());
assert_eq!(cfg.settings.unwrap()["phpantom"]["indexing"]["extensions"], json!([]));
let mut other = server("phoxite");
configure_server(&mut other, tmp.path(), tmp.path(), &s);
assert_eq!(other.settings, None);
}
#[test]
fn go_constraints_change_only_protocol_settings() {
use serde_json::json;
+3 -3
Переглянути файл
@@ -178,14 +178,14 @@ The table lists every built-in language definition. Server and debugger names in
| Terraform | `terraform` | `.tf`, `.tofu`, `.tftest.hcl` | Yes | Yes | **terraform-ls** | — |
| Terraform Variables | `terraform-vars` | `.tfvars` | Yes | Yes | **terraform-ls** | — |
| TOML | `toml` | `.toml` | Yes | Yes | **taplo** | — |
| Twig | `twig` | `.twig` | Yes | — | **phoxite** (with PHP) | — |
| Twig | `twig` | `.twig` | Yes | — | **phpantom** or **phoxite** (with PHP) | — |
| TypeScript | `typescript` | `.ts`, `.mts`, `.cts` | Yes | Yes | **vtsls** → **typescript-language-server** + **angular-language-server** + **oxlint** + **biome** | **js-debug** |
| TypeScript JSX | `typescriptreact` | `.tsx` | Yes | Yes | **vtsls** → **typescript-language-server** + **oxlint** + **biome** | **js-debug** |
| Typst | `typst` | `.typ` | — | — | **tinymist** | — |
| Vue | `vue` | `.vue` | Yes | — | **vue-language-server**, **vtsls** + **oxlint** | — |
| Xcode Config | `xcconfig` | `.xcconfig` | Yes | — | — | — |
| XML | `xml` | `.xml`, `.xsd`, `.xsl`, `.xslt`, `.svg`, … | Yes | Yes | **lemminx** | — |
| YAML | `yaml` | `.yaml`, `.yml` | Yes | Yes | **yaml-language-server** | — |
| XML | `xml` | `.xml`, `.xsd`, `.xsl`, `.xslt`, `.svg`, … | Yes | Yes | **lemminx** + **phpantom** (with PHP) | — |
| YAML | `yaml` | `.yaml`, `.yml` | Yes | Yes | **yaml-language-server** + **phpantom** (with PHP) | — |
| Zig | `zig` | `.zig`, `.zon` | Yes | Yes | **zls** | **codelldb** |
Notes:
+20 -6
Переглянути файл
@@ -1,6 +1,6 @@
---
title: "PHP"
description: "Intelephense and Phoxite, PHP interpreters and language level, Composer, PHPUnit and Pest, PHPStan, Xdebug debugging, Blade and Twig templates, and Laravel, Symfony and other framework support."
description: "Intelephense, PHPantom and Phoxite, PHP interpreters and language level, Composer, PHPUnit and Pest, PHPStan, Xdebug debugging, Blade and Twig templates, and Laravel, Symfony and other framework support."
---
OpenIDEA highlights PHP files (`.php`, `.phtml`, `.phpt` and older `.php3`–`.php5`, plus files starting with `<?php` or a `php` shebang), Blade views (`.blade.php`) and Twig templates (`.twig`) out of the box. Completion, navigation, refactoring and diagnostics come from Intelephense. Composer scripts, PHPUnit/Pest suites and Laravel's development server are detected as run configurations, and Xdebug sessions run through the PHP Debug adapter. See the [support matrix](/en/languages/index) for other languages.
@@ -10,13 +10,15 @@ OpenIDEA highlights PHP files (`.php`, `.phtml`, `.phpt` and older `.php3`–`.p
| Server | When it runs |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `intelephense` | Default. Workspace root: `composer.json`, `.phpactor.json` or `index.php`. |
| `phpantom` | Fallback: used only while Intelephense is not installed. |
| `phpantom` | Fallback with its own framework, Blade and Twig support (see [Frameworks](#frameworks)): used while Intelephense is not installed, or when you pick it in **Settings › Languages & Frameworks › Language Servers**. |
| `phpactor` | Fallback: used only while neither server above is installed. |
| `phoxite` | Alternative with its own framework, Blade and Twig support (see [Frameworks](#frameworks)): used while no server above is installed, or when you pick it in **Settings › Languages & Frameworks › Language Servers**. |
| `devsense-php-ls` | Alternative whose engine ships as native builds, so the server itself needs no Node or PHP: used while no server above is installed, or when you pick it in **Settings › Languages & Frameworks › Language Servers**. |
| `laravel-lsp` | Laravel projects only (below an `artisan` file): hover, definition and completion inside `config('…')`, `route('…')` and `view('…')`. |
A Blade view is served by the same servers as the project's PHP files. While Phoxite or DEVSENSE serves a project, `laravel-lsp` is not started: they answer the Laravel strings themselves.
A Blade view is served by the same servers as the project's PHP files. While PHPantom, Phoxite or DEVSENSE serves a project, `laravel-lsp` is not started: they answer the Laravel strings themselves.
PHPantom, where it is the project's PHP server, also reads Twig templates, and YAML and XML files: Symfony and Drupal configuration, Doctrine mappings and XLIFF translation catalogues. It runs once for all of them, next to those languages' own servers, and is never started for a project without PHP.
Phoxite, where it is the project's PHP server, also reads files of other languages: Twig templates, `.env` files and Laravel's `lang/*.json`. It runs once for all of them, next to those languages' own servers, and is never started for a project without PHP.
@@ -70,6 +72,8 @@ Also on this page:
Phoxite receives the same settings: a language level you choose (for **Auto** it reads `composer.json` itself), the include paths, the additional stubs, and the PHP interpreter for the analysers it runs. Its own settings, such as `frameworks` to turn a framework's support on or off (`{ "frameworks": { "wordpress": "disabled" } }`), go in **Settings › Languages & Frameworks › Language Servers › Phoxite › Workspace Configuration**, or in a `phoxite.json` at the project root.
PHPantom reads the PHP version from `composer.json` (or its own `.phpantom.toml`) and does not use the include paths or additional stubs. It is told the project is trusted, so it runs the project's PHPStan, PHP_CodeSniffer and formatters without asking, and it skips the folders excluded in **Settings › Project Structure** and **Settings › Editor › File Types** and indexes the extensions added to PHP there (such as `module` for Drupal). Its own settings go in a `.phpantom.toml` at the project root.
### Composer
In a Composer project without `vendor/`, or whose installed packages differ from `composer.lock`, a banner "Composer dependencies are not installed" appears above PHP files and `composer.json`, with **Install** (runs `composer install` on the configured PHP) and **Ignore**.
@@ -107,33 +111,43 @@ See [Debugging](/en/guide/debugging).
## Frameworks
Run configurations and template highlighting work with any PHP server. The names a framework gives things (routes, views, services, configuration keys, hooks) are understood by Phoxite: where a section says "with Phoxite", pick it as the PHP server in **Settings › Languages & Frameworks › Language Servers**. Phoxite finds the frameworks of a project from `composer.json` and their marker files, and supports each one it finds.
Run configurations and template highlighting work with any PHP server. The names a framework gives things (routes, views, services, configuration keys, hooks) are understood by PHPantom and Phoxite: where a section says "with PHPantom" or "with Phoxite", pick that server as the PHP server in **Settings › Languages & Frameworks › Language Servers**. Both find the frameworks of a project from the project itself and need no setup.
### Laravel
- **Run and debug**: an `artisan serve` configuration.
- **Blade views** (`.blade.php`) are highlighted: HTML, directives, `{{ }}` and `{!! !!}` echoes and the PHP inside them, with `{{-- --}}` comments.
- **Laravel LSP**, with Intelephense: hover, definition and completion inside `config('…')`, `route('…')` and `view('…')`.
- **With PHPantom**: completion, navigation, Find Usages and "unknown" warnings for route names, views, config keys, translation keys, middleware, gates and policies, Eloquent relations, scopes and columns, Livewire components and Folio pages; completion, hover, navigation and problems inside Blade views, with the types of the variables a view is rendered with.
- **With Phoxite**: completion, navigation, Find Usages, rename and "undefined" warnings for route names, views, config keys, translation keys, environment variables, validation rules, Eloquent columns and relations, Livewire components and Inertia pages; completion, hover, signature help and navigation inside Blade views; Find Usages and Rename of a key in `.env` and in `lang/*.json`.
### Symfony
- **Twig templates** (`.twig`) are highlighted: HTML, with tags, expressions and `{# #}` comments; blocks fold.
- **With PHPantom**: completion, navigation, Find Usages and "unknown" warnings for route names, template names, services and parameters, translation keys, form and validation options, events and Messenger handlers, across PHP, YAML, XML and Twig; Doctrine entities, repositories, mapping files and DQL. In Twig templates, in Symfony projects or not: completion, hover, navigation and problems for template names, blocks, filters, functions and the variables a render passes.
- **With Phoxite**: completion, navigation and rename for route names, template names, services and parameters, translation keys and Doctrine fields; in Twig templates, completion, hover, navigation (to an extended or included template, a function, a filter, a route), rename, the outline, formatting and problems.
### WordPress, Drupal, Magento and Joomla
With PHPantom, for WordPress and Drupal: WordPress core's types come from `php-stubs/wordpress-stubs` once Composer installs it, with return types that follow the arguments, and hook names complete, navigate between the places that fire and listen to them, and rename. Drupal services, entity types, hooks, routes, permissions, configuration names and plugin IDs complete and navigate in PHP and in a module's YAML, and the ones nothing declares are reported.
With Phoxite, in PHP: completion, navigation and Find Usages for the platform's names, such as WordPress hooks, shortcodes, options and block names, Drupal services, routes and permissions, Magento's events, configuration paths, ACL resources and layout handles, Joomla's language keys, layouts and form fields.
Without Phoxite, add a platform's stubs under **Additional stubs** (for example `wordpress`) and its folder under **Include paths**.
With Intelephense, add a platform's stubs under **Additional stubs** (for example `wordpress`) and its folder under **Include paths**.
### CodeIgniter, Yii, CakePHP and Laminas
With Phoxite, in PHP: completion, navigation and Find Usages for the framework's names (routes, views or templates, config keys, translation messages, services and components), and the types of the services, models and view variables the framework provides.
With PHPantom, for Yii 3: route names, views, aliases, DI definitions, params and translation message IDs complete, navigate and are checked, read from the application's configuration without booting it.
### Tempest
With PHPantom: completion, hover, navigation and problems inside `.view.php` templates and view components, with the types of the data a view is rendered with; component tags and view paths complete and navigate.
## Limitations
- With Intelephense, PHPantom, Phpactor or DEVSENSE, Blade views and Twig templates are highlighted but get no code insight of their own (a Blade view is read as PHP); with Phoxite they do.
- With Intelephense, Phpactor or DEVSENSE, Blade views and Twig templates are highlighted but get no code insight of their own (a Blade view is read as PHP); with PHPantom or Phoxite they do.
- Run with Coverage is not available for PHPUnit.
- Debugging needs the Xdebug extension in your PHP; the IDE does not install it.
- With **Run in target** set to a Docker or Compose target, the language servers still run on this machine and read the mounted files; Phpactor still needs a local `php`.
+3 -3
Переглянути файл
@@ -172,14 +172,14 @@ IDE 安装工具从不需要 `sudo`。工具装在本地数据目录下 IDE 自
| Terraform | `terraform` | `.tf`, `.tofu`, `.tftest.hcl` | 是 | 是 | **terraform-ls** | — |
| Terraform Variables | `terraform-vars` | `.tfvars` | 是 | 是 | **terraform-ls** | — |
| TOML | `toml` | `.toml` | 是 | 是 | **taplo** | — |
| Twig | `twig` | `.twig` | 是 | — | **phoxite**(随 PHP) | — |
| Twig | `twig` | `.twig` | 是 | — | **phpantom** 或 **phoxite**(随 PHP) | — |
| TypeScript | `typescript` | `.ts`, `.mts`, `.cts` | 是 | 是 | **vtsls** → **typescript-language-server** + **angular-language-server** + **oxlint** + **biome** | **js-debug** |
| TypeScript JSX | `typescriptreact` | `.tsx` | 是 | 是 | **vtsls** → **typescript-language-server** + **oxlint** + **biome** | **js-debug** |
| Typst | `typst` | `.typ` | — | — | **tinymist** | — |
| Vue | `vue` | `.vue` | 是 | — | **vue-language-server**, **vtsls** + **oxlint** | — |
| Xcode Config | `xcconfig` | `.xcconfig` | 是 | — | — | — |
| XML | `xml` | `.xml`, `.xsd`, `.xsl`, `.xslt`, `.svg`, … | 是 | 是 | **lemminx** | — |
| YAML | `yaml` | `.yaml`, `.yml` | 是 | 是 | **yaml-language-server** | — |
| XML | `xml` | `.xml`, `.xsd`, `.xsl`, `.xslt`, `.svg`, … | 是 | 是 | **lemminx** + **phpantom**(随 PHP) | — |
| YAML | `yaml` | `.yaml`, `.yml` | 是 | 是 | **yaml-language-server** + **phpantom**(随 PHP) | — |
| Zig | `zig` | `.zig`, `.zon` | 是 | 是 | **zls** | **codelldb** |
说明:
+20 -6
Переглянути файл
@@ -1,6 +1,6 @@
---
title: "PHP"
description: "Intelephense 与 Phoxite、PHP 解释器与语言级别、Composer、PHPUnit 与 Pest、PHPStan、Xdebug 调试、Blade 与 Twig 模板,以及 Laravel、Symfony 等框架支持。"
description: "Intelephense、PHPantom 与 Phoxite、PHP 解释器与语言级别、Composer、PHPUnit 与 Pest、PHPStan、Xdebug 调试、Blade 与 Twig 模板,以及 Laravel、Symfony 等框架支持。"
---
OpenIDEA 开箱即可高亮 PHP 文件(`.php`、`.phtml`、`.phpt` 以及老式的 `.php3`–`.php5`,还有以 `<?php` 或 `php` shebang 开头的文件)、Blade 视图(`.blade.php`)和 Twig 模板(`.twig`)。补全、跳转、重构和诊断由 Intelephense 提供。Composer 脚本、PHPUnit/Pest 测试套件以及 Laravel 的开发服务器会被识别为运行配置,Xdebug 调试通过 PHP Debug 适配器进行。其他语言见[支持矩阵](/zh/languages/index)。
@@ -10,13 +10,15 @@ OpenIDEA 开箱即可高亮 PHP 文件(`.php`、`.phtml`、`.phpt` 以及老
| 服务器 | 启用条件 |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `intelephense` | 默认。工作区根:`composer.json`、`.phpactor.json` 或 `index.php`。 |
| `phpantom` | 备选:仅在未安装 Intelephense 时使用。 |
| `phpantom` | 备选,自带框架、Blade 和 Twig 支持(见[框架](#框架)):在未安装 Intelephense 时使用,或在 **设置 › 语言和框架 › 语言服务器** 中选中它时使用。 |
| `phpactor` | 备选:仅在以上两个服务器都未安装时使用。 |
| `phoxite` | 备选,自带框架、Blade 和 Twig 支持(见[框架](#框架)):仅在以上服务器都未安装时使用,或在 **设置 › 语言和框架 › 语言服务器** 中选中它时使用。 |
| `devsense-php-ls` | 备选,引擎为各平台原生构建,服务器本身无需 Node 或 PHP:仅在以上服务器都未安装时使用,或在 **设置 › 语言和框架 › 语言服务器** 中选中它时使用。 |
| `laravel-lsp` | 仅限 Laravel 项目(`artisan` 文件所在目录之下):在 `config('…')`、`route('…')`、`view('…')` 中提供悬停、跳转和补全。 |
Blade 视图由为项目 PHP 文件提供服务的同一组服务器处理。Phoxite 或 DEVSENSE 为项目提供服务时不会启动 `laravel-lsp`:Laravel 相关的字符串由它们自己处理。
Blade 视图由为项目 PHP 文件提供服务的同一组服务器处理。PHPantom、Phoxite 或 DEVSENSE 为项目提供服务时不会启动 `laravel-lsp`:Laravel 相关的字符串由它们自己处理。
PHPantom 作为项目的 PHP 服务器时,还会读取 Twig 模板,以及 YAML 和 XML 文件:Symfony 和 Drupal 的配置、Doctrine 映射和 XLIFF 翻译目录。这些文件共用同一个 PHPantom 进程,与各自语言的服务器并存;没有 PHP 的项目不会启动它。
Phoxite 作为项目的 PHP 服务器时,还会读取其他语言的文件:Twig 模板、`.env` 文件和 Laravel 的 `lang/*.json`。这些文件共用同一个 Phoxite 进程,与各自语言的服务器并存;没有 PHP 的项目不会启动它。
@@ -70,6 +72,8 @@ Intelephense 会按项目的 PHP 版本检查代码(见下文“语言级别
Phoxite 也会收到这些设置:你选定的语言级别(**自动** 时它自己读取 `composer.json`)、包含路径、附加存根,以及运行分析器所用的 PHP 解释器。它自己的设置,例如用 `frameworks` 开启或关闭某个框架的支持(`{ "frameworks": { "wordpress": "disabled" } }`),写在 **设置 › 语言和框架 › 语言服务器 › Phoxite › 工作区配置** 中,或项目根目录的 `phoxite.json` 里。
PHPantom 自己从 `composer.json`(或它自己的 `.phpantom.toml`)读取 PHP 版本,不使用包含路径和附加存根。IDE 会告知它项目已受信任,因此它无需再询问即可运行项目的 PHPStan、PHP_CodeSniffer 和格式化工具;它会跳过 **设置 › 项目结构** 和 **设置 › 编辑器 › 文件类型** 中排除的目录,并索引在那里为 PHP 添加的扩展名(例如 Drupal 的 `module`)。它自己的设置写在项目根目录的 `.phpantom.toml` 中。
### Composer
Composer 项目没有 `vendor/`,或已安装的包与 `composer.lock` 不一致时,PHP 文件和 `composer.json` 顶部会出现 “未安装 Composer 依赖” 横幅,提供 **安装**(用所配置的 PHP 执行 `composer install`)和 **忽略**。
@@ -107,33 +111,43 @@ PHPUnit 运行配置类型包含 **目标**、**配置文件**、**测试过滤
## 框架
运行配置和模板高亮适用于任何 PHP 服务器。框架为各种东西起的名字(路由、视图、服务、配置键、钩子)由 Phoxite 理解:下文标注“使用 Phoxite 时”的功能,需要在 **设置 › 语言和框架 › 语言服务器** 中把它选为 PHP 服务器。Phoxite 根据 `composer.json` 和各框架的标志文件识别项目使用的框架,并为识别出的每个框架提供支持。
运行配置和模板高亮适用于任何 PHP 服务器。框架为各种东西起的名字(路由、视图、服务、配置键、钩子)由 PHPantom 和 Phoxite 理解:下文标注“使用 PHPantom 时”或“使用 Phoxite 时”的功能,需要在 **设置 › 语言和框架 › 语言服务器** 中把对应的服务器选为 PHP 服务器。两者都从项目本身识别所用的框架,无需配置。
### Laravel
- **运行与调试**:`artisan serve` 配置。
- **Blade 视图**(`.blade.php`)有语法高亮:HTML、指令、`{{ }}` 和 `{!! !!}` 输出及其中的 PHP,注释为 `{{-- --}}`。
- **Laravel LSP**(配合 Intelephense):在 `config('…')`、`route('…')`、`view('…')` 中提供悬停、跳转和补全。
- **使用 PHPantom 时**:路由名、视图、配置键、翻译键、中间件、Gate 和策略、Eloquent 关联、作用域和字段、Livewire 组件和 Folio 页面的补全、跳转、查找用法和“未知”警告;Blade 视图内的补全、悬停、跳转和问题检查,并推断渲染视图时传入的变量类型。
- **使用 Phoxite 时**:路由名、视图、配置键、翻译键、环境变量、验证规则、Eloquent 字段和关联、Livewire 组件和 Inertia 页面的补全、跳转、查找用法、重命名和“未定义”警告;Blade 视图内的补全、悬停、签名帮助和跳转;`.env` 和 `lang/*.json` 中键的查找用法和重命名。
### Symfony
- **Twig 模板**(`.twig`)有语法高亮:HTML,以及标签、表达式和 `{# #}` 注释;块可以折叠。
- **使用 PHPantom 时**:在 PHP、YAML、XML 和 Twig 中,路由名、模板名、服务和参数、翻译键、表单和验证选项、事件和 Messenger 处理器的补全、跳转、查找用法和“未知”警告;Doctrine 实体、仓库、映射文件和 DQL。在 Twig 模板中(无论是否为 Symfony 项目):模板名、块、过滤器、函数以及渲染时传入的变量的补全、悬停、跳转和问题检查。
- **使用 Phoxite 时**:路由名、模板名、服务和参数、翻译键、Doctrine 字段的补全、跳转和重命名;在 Twig 模板中提供补全、悬停、跳转(到被继承或包含的模板、函数、过滤器、路由)、重命名、大纲、格式化和问题检查。
### WordPress、Drupal、Magento 和 Joomla
使用 PHPantom 时,对 WordPress 和 Drupal:Composer 安装 `php-stubs/wordpress-stubs` 后,WordPress 核心的类型来自它,返回类型随参数而定;钩子名可以补全、在触发和监听它的位置之间跳转,并可重命名。Drupal 的服务、实体类型、钩子、路由、权限、配置名和插件 ID 在 PHP 和模块的 YAML 中可以补全和跳转,未声明的名字会被报告。
使用 Phoxite 时,在 PHP 中为平台的名字提供补全、跳转和查找用法,例如 WordPress 的钩子、短代码、选项和区块名,Drupal 的服务、路由和权限,Magento 的事件、配置路径、ACL 资源和布局句柄,Joomla 的语言键、布局和表单字段。
不使用 Phoxite 时,在 **附加存根** 中加入平台的 stub(例如 `wordpress`),在 **包含路径** 中加入平台代码目录。
使用 Intelephense 时,在 **附加存根** 中加入平台的 stub(例如 `wordpress`),在 **包含路径** 中加入平台代码目录。
### CodeIgniter、Yii、CakePHP 和 Laminas
使用 Phoxite 时,在 PHP 中为框架的名字(路由、视图或模板、配置键、翻译消息、服务和组件)提供补全、跳转和查找用法,并推断框架提供的服务、模型和视图变量的类型。
使用 PHPantom 时,对 Yii 3:路由名、视图、别名、DI 定义、params 和翻译消息 ID 可以补全、跳转并被检查,均从应用配置中读取,无需启动应用。
### Tempest
使用 PHPantom 时:`.view.php` 模板和视图组件内的补全、悬停、跳转和问题检查,并推断渲染视图时传入的数据类型;组件标签和视图路径可以补全和跳转。
## 已知限制
- 使用 Intelephense、PHPantom、Phpactor 或 DEVSENSE 时,Blade 视图和 Twig 模板只有语法高亮,没有针对模板的代码智能(Blade 视图被当作 PHP 读取);使用 Phoxite 时则有。
- 使用 Intelephense、Phpactor 或 DEVSENSE 时,Blade 视图和 Twig 模板只有语法高亮,没有针对模板的代码智能(Blade 视图被当作 PHP 读取);使用 PHPantom 或 Phoxite 时则有。
- PHPUnit 不支持使用覆盖率运行。
- 调试需要 PHP 已安装 Xdebug 扩展,IDE 不负责安装。
- **在目标中运行** 设为 Docker 或 Compose 目标时,语言服务器仍在本机运行并读取挂载的文件;Phpactor 仍需要本机的 `php`。
+4 -2
Переглянути файл
@@ -10,7 +10,8 @@ ui-mode = "Blade"
# The PHP servers, in `php.toml`'s order, so a view is served by the server that
# serves the project's PHP. Phoxite knows the file as a Blade view; the others
# are told `php`, as they were before Blade was a language of its own.
# are told `php`, as they were before Blade was a language of its own. PHPantom
# serves the view as Blade all the same: it goes by the `.blade.php` extension.
[[language-servers]]
name = "intelephense"
command = "intelephense"
@@ -26,7 +27,8 @@ ignored-progress-token-prefixes = ["find_references", "goto_implementation"]
fallback = true
command = "phpantom_lsp"
args = []
root-markers = ["composer.json", "index.php"]
root-markers = ["composer.json", ".phpantom.toml", "index.php"]
replaces = ["laravel-lsp"]
install-hint = "Install PHPantom in Settings › Languages & Frameworks › Language Servers"
language-id = "php"
+3 -1
Переглянути файл
@@ -24,7 +24,9 @@ ignored-progress-token-prefixes = ["find_references", "goto_implementation"]
fallback = true
command = "phpantom_lsp"
args = []
root-markers = ["composer.json", "index.php"]
root-markers = ["composer.json", ".phpantom.toml", "index.php"]
# It answers the Laravel strings itself.
replaces = ["laravel-lsp"]
install-hint = "Install PHPantom in Settings › Languages & Frameworks › Language Servers"
[[language-servers]]
+11
Переглянути файл
@@ -18,3 +18,14 @@ args = []
root-markers = ["composer.json", "artisan", "index.php"]
joins = "php"
install-hint = "Install Phoxite in Settings › Languages & Frameworks › Language Servers"
# PHPantom, where it is the project's PHP server: completion, navigation,
# references and problems of template names, blocks, filters, functions, routes
# and the variables a render passes, with hover on the PHP behind them.
[[language-servers]]
name = "phpantom"
command = "phpantom_lsp"
args = []
root-markers = ["composer.json", ".phpantom.toml", "index.php"]
joins = "php"
install-hint = "Install PHPantom in Settings › Languages & Frameworks › Language Servers"
+11
Переглянути файл
@@ -16,3 +16,14 @@ tags = ["OpenTag", "CloseTag", "SelfClosingTag"]
name = "lemminx"
command = "lemminx"
install-hint = "Install Eclipse LemMinX (https://github.com/redhat-developer/vscode-xml/releases) and put the lemminx binary on PATH"
# PHPantom, where it is the project's PHP server: the same for Symfony's XML
# configuration, Doctrine's XML mappings and XLIFF translation catalogues.
[[language-servers]]
name = "phpantom"
command = "phpantom_lsp"
args = []
root-markers = ["composer.json", ".phpantom.toml", "index.php"]
joins = "php"
files = ["**/*.xml", "**/*.xlf", "**/*.xliff"]
install-hint = "Install PHPantom in Settings › Languages & Frameworks › Language Servers"
+11
Переглянути файл
@@ -34,3 +34,14 @@ install-hint = "npm i -g yaml-language-server"
"*.compose.*.yml",
"*.compose.*.yaml",
]
# PHPantom, where it is the project's PHP server: completion, navigation and
# references of the PHP classes, services, routes and other names Symfony and
# Drupal configuration uses, and problems for the ones nothing declares.
[[language-servers]]
name = "phpantom"
command = "phpantom_lsp"
args = []
root-markers = ["composer.json", ".phpantom.toml", "index.php"]
joins = "php"
install-hint = "Install PHPantom in Settings › Languages & Frameworks › Language Servers"