【求助】配置php语言服务器

系统:MacOs

通过 brew 安装 composer,此时其默认安装php最新版。

使用 composer 安装php-language-server

命令 composer global require felixfbecker/language-server

发现错误,不支持当前php版本,故用brew安装[email protected]

再次运行安装php-language-server的命令,

打开Emacs(purcell配置),打开test.php,尝试连接Eglot,报错[Eglot] -1:Server died

尝试运行php php-language-server.php,报错Could not open input file: php-language-server.php

在php文件所在目录运行 php ./php-language-server.php则产生如下报错

PHP Deprecated: Array and string offset access syntax with curly braces is deprecated in /Users/yifeng/.composer/vendor/netresearch/jsonmapper/src/JsonMapper.php on line 280

Deprecated: Array and string offset access syntax with curly braces is deprecated in /Users/yifeng/.composer/vendor/netresearch/jsonmapper/src/JsonMapper.php on line 280 PHP Fatal error: Uncaught LogicException: “throwOnError” is no longer supported, use “errorHandler” instead in /Users/yifeng/.composer/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php:125 Stack trace: #0 /Users/yifeng/.composer/vendor/nikic/php-parser/lib/PhpParser/ParserFactory.php(27): PhpParser\ParserAbstract->__construct(Object(PhpParser\Lexer), Array) #1 /Users/yifeng/.composer/vendor/felixfbecker/language-server/src/Project.php(39): PhpParser\ParserFactory->create(1, Object(PhpParser\Lexer), Array) #2 /Users/yifeng/.composer/vendor/felixfbecker/language-server/src/LanguageServer.php(76): LanguageServer\Project->__construct(Object(LanguageServer\LanguageClient)) #3 /Users/yifeng/.composer/vendor/felixfbecker/language-server/bin/php-language-server.php(31): LanguageServer\LanguageServer->__construct(Object(LanguageServer\ProtocolStreamReader), Object(LanguageServer\ProtocolStreamWriter)) #4 /Users/yifeng/.composer/vendor/bin/php-language-server.php(18): include(‘/Users/yifeng/…’) #5 {ma Fatal error: Uncaught LogicException: “throwOnError” is no longer supported, use “errorHandler” instead in /Users/yifeng/.composer/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php:125 Stack trace: #0 /Users/yifeng/.composer/vendor/nikic/php-parser/lib/PhpParser/ParserFactory.php(27): PhpParser\ParserAbstract->__construct(Object(PhpParser\Lexer), Array) #1 /Users/yifeng/.composer/vendor/felixfbecker/language-server/src/Project.php(39): PhpParser\ParserFactory->create(1, Object(PhpParser\Lexer), Array) #2 /Users/yifeng/.composer/vendor/felixfbecker/language-server/src/LanguageServer.php(76): LanguageServer\Project->__construct(Object(LanguageServer\LanguageClient)) #3 /Users/yifeng/.composer/vendor/felixfbecker/language-server/bin/php-language-server.php(31): LanguageServer\LanguageServer->__construct(Object(LanguageServer\ProtocolStreamReader), Object(LanguageServer\ProtocolStreamWriter)) #4 /Users/yifeng/.composer/vendor/bin/php-language-server.php(18): include(‘/Users/yifeng/…’) #5 {main} thrown in /Users/yifeng/.composer/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php on line 125

大佬们帮帮忙,多谢了

这个太久没更新了,试一试其他的 PHP LSP Server,在 https://langserver.org/ 搜索 PHP,除了这个,还有别的正常维护的

你装了 PHP 7.4,但是你下面的命令中的 PHP,根据报错

Array and string offset access syntax with curly braces

应该是 PHP 8,运行 php --version,查看你在用的 PHP 版本,版本不对的话,改为 PHP 7.4 的路径,用 brew info 或者 ls [email protected] 查看安装路径。

另外,报错提示直接复制粘贴,贴图不如文本。

多谢多谢,明白了,我去试试