Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug #24

Closed
lgabeskiria opened this issue Sep 11, 2016 · 25 comments
Closed

Debug #24

lgabeskiria opened this issue Sep 11, 2016 · 25 comments

Comments

@lgabeskiria
Copy link
Contributor

Is it possible to debug language server with vscode?

@felixfbecker
Copy link
Owner

felixfbecker commented Sep 11, 2016

Sure! Have you tried it with https://github.com/felixfbecker/vscode-php-debug?

This launch.json config works to run PHPUnit tests:

    {
      "name": "PHPUnit",
      "type": "php",
      "request": "launch",
      "program": "${workspaceRoot}\\vendor\\phpunit\\phpunit\\phpunit",
      "args": ["--bootstrap", "vendor/autoload.php", "tests"],
      "cwd": "${workspaceRoot}"
    }

If you want to debug it in action, I recommend to open vscode-php-intellisense in a seperate window and symlink vendor/felixfbecker/language-server to the git clone of the language server. Then in the window with php-language-server, you can use the "Listen for XDebug" configuration and set breakpoints. Then launch the extension from the window with vscode-php-intellisense.

@lgabeskiria
Copy link
Contributor Author

I repeated steps that you described but nothing happens.

{
   "name": "Listen for XDebug",
   "type": "php",
   "request": "launch",
   "port": 9000
}

@felixfbecker
Copy link
Owner

Running PHPUnit or debugging with vscode-php-intellisense? Did you install XDebug properly?

@lgabeskiria
Copy link
Contributor Author

running debug, yes XDebug is properly installed. I'll double check and let you know.

@felixfbecker
Copy link
Owner

You might wanna look into the troubleshooting section of vscode-php-debug. In particular, enable xdebug.remote_log in your php.ini.

@felixfbecker
Copy link
Owner

Try to run the tests with some breakpoints and see if that works.

@felixfbecker
Copy link
Owner

Just tried it again and it works for me.
Creating the symlink:

felix@FELIX-PC ~\git\OpenSource\vscode-php-intellisense\vendor\felixfbecker [master ≡]
$ rm -re -fo .\language-server\

felix@FELIX-PC ~\git\OpenSource\vscode-php-intellisense\vendor\felixfbecker [master ≡]
$ New-Symlink language-server ~\git\OpenSource\php-language-server

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d----l       11.09.2016     20:30                language-server

launch.json in php-language-server:

{
      "name": "Listen for XDebug",
      "type": "php",
      "request": "launch"
}

And the included "Launch Extension" config from vscode-php-intellisense. Of course you then need to open a PHP project so the extension gets activated.

@lgabeskiria
Copy link
Contributor Author

without port option?

@felixfbecker
Copy link
Owner

Port defaults to 9000.

@felixfbecker
Copy link
Owner

felixfbecker commented Sep 11, 2016

Can you debug PHPUnit at least?

@lgabeskiria
Copy link
Contributor Author

when I launch extension development host and execute command to list symbols in document nothing happens, progress bar just runs.

@lgabeskiria
Copy link
Contributor Author

I just removed all breakpoints and extension work again, but without debugging :(

@felixfbecker
Copy link
Owner

Can you run PHPUnit with the debugger?

@lgabeskiria
Copy link
Contributor Author

I have finally launched debugging. I've just unchecked warnings and exceptions in breakpoints section of debugger.

@felixfbecker
Copy link
Owner

It is very hard for me to help you if you provide so little information... What did you finally launch (PHPUnit/intellisense)? Can you hit breakpoints?

@lgabeskiria
Copy link
Contributor Author

Yes, I can hit breakpoints. PHPUnit, Debugger and intellisense work.

@felixfbecker
Copy link
Owner

So everything is working now? It is probably a good idea to add some guidance to the readme.

@lgabeskiria
Copy link
Contributor Author

lgabeskiria commented Sep 11, 2016

Yes everything works fine. I don't know why, but exceptions and warnings option in debugger were causing this behavior.

@felixfbecker
Copy link
Owner

That's not the way it should be... please open an issue at vscode-php-debug. Make sure to include what versions of PHP/XDebug you are running and the log from xdebug.remote_log :)

@lgabeskiria
Copy link
Contributor Author

ok. thank's for help.

@bmax
Copy link
Contributor

bmax commented Nov 8, 2017

Hello @felixfbecker,

Trying to do the same thing as @lgabeskiria and use xdebug on the php-language-server.

I followed all your steps but am not ableto get the breakpoints to execute. the PHPUnit xdebug does work and when I use the Listen for XDebug and launch extension development host, I get this:

image

as you can see there is Request's coming through but they never change from Running and I can't get that breakpoint to execute on https://github.com/felixfbecker/php-language-server/blob/master/src/LanguageServer.php#L114

Any help would be appreciated thanks!!

@felixfbecker
Copy link
Owner

I am confused, are you saying PHPUnit works or does not work?

Try setting the environment variable COMPOSER_ALLOW_XDEBUG to 1

@bmax
Copy link
Contributor

bmax commented Nov 8, 2017

PHPUnit does work. I just added COMPOSER_ALLOW_XDEBUG as an env variable and it worked, interesting.

Thank you.

@felixfbecker
Copy link
Owner

Could you do a PR to add that to the README?

This is the reason why it's needed:

// If XDebug is enabled, restart without it
(new XdebugHandler(Factory::createOutput()))->check();

@bmax
Copy link
Contributor

bmax commented Nov 8, 2017

Sure! I'll do that tomorrow. -- How come we need to restart when xdebug is enabled?

Thanks for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants