Closed Alexey-T closed 2 years ago
@johntor The author of RJ TextEd has the forum topic about LSP server for PHP. https://www.rj-texted.se/Forum/viewtopic.php?f=23&t=5005 Maybe you can try his steps?
This seems like an updated version: https://github.com/zobo/php-language-server
Maybe someone can give 'steps' how to install+setup the server?
All these are based on the same project that I mentioned before. The installation should be easy for every user, which is not! In Sublime you just download a plugin and you are ready to go. Most users want to jump into a tool and get 100% of it without touching any parameter! I'm not one of these but these days I'm so busy so I can not test anything. Keep on and I will be back...
I tried zobo/php-language-server on Windows and get the "server console window" opened via CudaText. But that's all that happens. I think the server is not initialized. But I don't get any messages what is wrong. There are also some other PHP servers listed on https://langserver.org/.
I tried zobo/php-language-server on Windows and get the "server console window" opened via CudaText. But that's all that happens. I think the server is not initialized. But I don't get any messages what is wrong. There are also some other PHP servers listed on https://langserver.org/.
It is based on felixfbecker/php-language-server
see the first post...
The zobo project was update 2 months ago and has 5 issues. So i think it should work or nobody is using it. ;) Also Felix Becker works on it.
@veksha I want to donate you e.g. $30 if you help with this issue.
https://github.com/CudaText-addons/cuda_lsp/pull/11 this PR is required for making https://github.com/zobo/php-language-server work with Cuda_LSP.
(with --tcp-server=127.0.0.1:12345
switch at least. Stdio mode for this server is not working for me)
configure for Cuda_LSP + zobo/php-language-server lsp_php.json:
{
"name": "PHP",
"lexers": {
"PHP": "php"
},
"tcp_port": 12345,
}
start lsp server, for example: php bin/php-language-server.php --tcp-server=127.0.0.1:12345
@Alexey-T , @TomBraider42 , @johntor , @DUOLabs333 please test this if you can and report.
PS: I think autocompletion (and diagnostics) is not working, other features seem to work (go to definition, hover, go to references). I will look into it a bit later.
On Ubuntu 20 I cannot install PHP 8 using this doc https://linuxize.com/post/how-to-install-php-8-on-ubuntu-20-04/
I got
user@PC:~$ sudo apt install php8.0-cli
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php8.0-cli : Depends: libpcre2-8-0 (>= 10.38) but 10.34-7 is to be installed
E: Unable to correct problems, you have held broken packages.
so I cannot test it here. can you write the wiki topic like these, please?
18.1 LSP server for Python
18.2 LSP server for CSS/SCSS/LESS
18.3 LSP server for Nim
18.4 LSP server for Rust
18.5 LSP server for AutoHotkey
18.6 LSP server for JavaScript/ReactJS
18.7 LSP servers for C/C++
18.8 LSP server for Red
On Ubuntu 20 I cannot install PHP 8 using this doc
try XAMPP https://www.apachefriends.org/download.html
can you write the wiki topic like these, please?
of course
Installed XAMP, now can run php using fullpath. but server cannot run!
user@PC:~$ /opt/lampp/bin/php /home/user/repos/php-language-server/bin/php-language-server.php --tcp-server=127.0.0.1:12345
PHP Fatal error: Uncaught Error: Class "LanguageServer\StderrLogger" not found in /home/user/repos/php-language-server/bin/php-language-server.php:18
Stack trace:
#0 {main}
thrown in /home/user/repos/php-language-server/bin/php-language-server.php on line 18
using latest GH version of php-server.
@johntor What do you mean "install a plugin"? Don't you still have to start the server?
@Alexey-T You need to use composer, there seems to be dependencies you are missing.
php composer.phar update
should work, within the project folder.
php composer.phar update
should work, within the project folder.
In what project folder? in the folder of php-language-server it don't work:
user@PC:~/repos/php-language-server$ php composer.phar update
Could not open input file: composer.phar
Well, you have to install it. It should be available in whatever repo you use, eg apt-get install compsoer
, or pacman install composer
. Then just use composer update
in the project directory.
Hmm, you are going to have to do it manually (I'm not sure why it's doing that, but I'm not going to try and debug it) --- follow this: https://getcomposer.org/download/
Composer installed (after I call 'apt install jsonlint') Now I call 'composer update' and got this
You have to upgrade your php. Can you try installing from apt
again.
Ok, tried that - I need PHP 7.3 (from my screnshot) and I run
sudo apt install php7.3-cli
and got APT error
The following packages have unmet dependencies:
php7.3-cli : Depends: libpcre2-8-0 (>= 10.38) but 10.34-7 is to be installed
You actually need at least 7.4, can you install libpcre2-8-0
separately?
Installed PHP 7.4! Now this error in Composer
Try apt install php7.4-xml
(this part of the reason I do not like php, as composer is third-party, so it can't cover all needs).
I got next error (soemthing about missing PHP extension 'mbstring'?) . I give up with Composer. I cannot test it. Maybe will test on Win10 later.
You also need apt-get install php7.4-mbstring
. Yeah, php is a whole thing.
sorry, a forgot about all dependencies. make notes of all your steps, Alexey! (for wiki) I used Muon package manager in Lubuntu to search for php dom and others dependencies.
my steps are needed for wiki? but they are failed steps. i even cannot run the server!
There's a step-by-step process to getting it to work.
does this error tell us, that I must use PHP8? it is the same when I run PHP7.4 and PHP8.
user@PC:~$ cd ~/repos/php-language-server/bin/
user@PC:~/repos/php-language-server/bin$ php php-language-server.php
PHP Fatal error: Uncaught Error: Class 'LanguageServer\StderrLogger' not found in /home/user/repos/php-language-server/bin/php-language-server.php:18
Stack trace:
#0 {main}
thrown in /home/user/repos/php-language-server/bin/php-language-server.php on line 18
Huh, this actually is an opened issue on the old server: https://github.com/felixfbecker/vscode-php-intellisense/issues/440
my steps are needed for wiki? but they are failed steps. i even cannot run the server!
i think it's just
Class 'LanguageServer\StderrLogger is in this file : do you have it?
You may also have to composer run-script --working-dir=$WORKDIR parse-stubs
@veksha yes, I have this file - we use the same GH repo with you.
make sure you have read Installation section of readme: https://github.com/zobo/php-language-server#installation
composer update
and composer run-script --working-dir=vendor/felixfbecker/language-server parse-stubs
are mentioned there.
Thanks. I will try it on Win10 - where I will get XAMPP or just PHP8. my Ubuntu config is not good for that
if all go well composer update
should run script parse-stubs automatically (i think)
(Updated the LSP plugin in addons)
autocompletion is working actually. it was not working because i opened .php file that is outside of current Cud project directory.
In Cuda_LSP config there is a parameter named root_dir_source
. For zobo's server to index .php files they must be inside this dir.
In Cud's Project manager you must save your project file to your php project location. otherwise the root_dir will be wrong.
diagnostics work too.
they will not work if the file is outside of current workspace.
good, that it works. Please write me to support (at ) uvviewsoft.com so I can send you the donation
I wrote help text, pls check, https://wiki.freepascal.org/CudaText_plugins#LSP_server_for_PHP
{
"name": "PHP",
"lexers": {
"PHP": "php"
},
"cmd_unix": ["php", "folder_of_server/bin/php-language-server.php", "--tcp-server=127.0.0.1:12345"],
"cmd_windows": ["php.exe", "folder_of_server\\bin\\php-language-server.php", "--tcp-server=127.0.0.1:12345"],
"tcp_port": 12345
}
if tcp_port is specified cmd_windows
and other cmd_* are ignored. see https://github.com/Alexey-T/CudaText/issues/4186
it is better to change this in wiki to: "you must start php-language-server
from terminal" until issue is resolved.
Edited the wiki part. OK now?
Updated the wiki. we have solved the issue now. @johntor
server installation steps for Ubuntu 20.04.4 and PHP 7.4.3
composer update
inside php-language-server directoryphp bin/php-language-server.php
and ensure you see no errors.so php-dom extension is the only needed for this server to work. and it must be installed before you run composer update
.
EDIT: then I just upgraded to php8.1 and server still works ok.
Where php-dom is described? found https://iqcode.com/code/php/install-php-dom-extension-ubuntu which tells it's "php-xml" !
@johntor wrote in #3899
Bad news from here! I couldn't find an LSP Server for PHP working out of the box. First I tried felixfbecker/php-language-server which seemed promising but was released on 2018 and it is depended on other external projects that have changed over the years and now there are 240 Open issues. I tried to some fixes but it is not reliable and is hard to suggest it to simple users.
Then I tried bmewburn/vscode-intelephense which is very nice and it is working great in VSCode. The second is written in ts and needs a lot of patching to fix it for Cud and will be hard to maintain in the future.
Because I have limited spare time these days to get involved, I have to admit defeat!
from Alexey: wanted the working setup for LSP Client for PHP syntax. Like at the end of https://wiki.freepascal.org/CudaText_plugins