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

Getting xdebug to work with phpstorm and kalabox #1507

Closed
jsibley2 opened this Issue Jul 30, 2016 · 15 comments

Comments

Projects
None yet
10 participants
@jsibley2

jsibley2 commented Jul 30, 2016

I'm unclear about how much setup I need to do to get xdebug to work with phpstorm and kalabox.

The message I'm getting now is "Debug session was finished without being paused. It may be caused by path mappings misconfiguration or not synchronized local and remote projects. To figure out the problem check path mappings configuration for 'appserver' server at PHP|Servers or enable Break at first line in PHP scripts option (from Run menu).

I think that this is at least one place I need to add some details:

image

@jsibley2

This comment has been minimized.

jsibley2 commented Aug 4, 2016

I believe that the issue is that the IDE is looking for the location of the php executable.

Am I correct that the php executable is run as a service within appserver, so there aren't necessarily local files with php.exe, etc.?

If so, is there a better process than:

  • check php version (e.g., in phpinfo())
  • download and install that version on local computer
  • configure IDE to use this php interpreter

Thanks.

@pirog

This comment has been minimized.

Member

pirog commented Aug 4, 2016

@jsibley2 location of the php executable should not matter. xdebug is typically run as a remote service and i personally have never seen this as required info in any IDE i have used in the past.

Have you looked at this?
https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm

or this?
#202

@reynoldsalec

This comment has been minimized.

Contributor

reynoldsalec commented Sep 23, 2016

@jsibley2 @ashday I was able to get debugging working in PHPStorm by using the default settings:

screen shot 2016-09-23 at 11 34 21 am

After clicking the button "Start Listening for PHP Debug Connections" and creating a breakpoint (I just put one in my index.php file), I initiated a connection by requesting my site in Chrome with the XDEBUG_SESSION_START parameter: http://kalabox-drupal7.kbox/?XDEBUG_SESSION_START=1

PHPStorm immediately popped up with this window; these defaults it provided me were correct:

screen shot 2016-09-23 at 11 31 20 am

Note that I probably should have changed the path on the server to reflect the actual path of index.php; you'll see there's an error in my debugging console related to that in the next screenshot.

After this, my breakpoint halted execution and I was receiving variables:

screen shot 2016-09-23 at 11 32 46 am

The other catch I've seen pop up in other issues is that people already have DNSmasq running on port 9000 and that can disrupt xdebug, so could be something to look into if you're still having issues.

If this is helpful, I can add it to our Docs.

@pirog

This comment has been minimized.

Member

pirog commented Sep 23, 2016

@reynoldsalec prepend.php is loaded by the php.ini and it contains the PANTHEON env config. It SHOULD exist locally in APP_ROOT/config/php/prepend.php. Not sure if you can set that somewhere or not.

@mikeethedude

This comment has been minimized.

mikeethedude commented Sep 23, 2016

@reynoldsalec @jsibley2 This might also be useful to note here. We typically use the tools in PHPStorm a little differently I guess. I set it up to work so that clicking the little bug icon under Run->debug(named service) would launch the xdebug session in your chosen browser.

Under Preferences-> Languages & Frameworks -> PHP -> Servers

I had to set the path mapping for the code directory and the php/prepend.php file.

image

Then going to Run->Edit Configurations

You hit the + at the top left and add a new PHP web Application.

image

That's all there was to it for me. I added some breakpoints and hit this icon.
eiq_portal_module_-cgt-____kalabox_apps_cgt

@jsibley2

This comment has been minimized.

jsibley2 commented Sep 24, 2016

Thank you for trying this and documenting it.

So, one thing that wasn't clear to me was that I should choose the top directory of the Pantheon application, and that I shouldn't start at \code, as that wouldn't let me set the mapping for prepend.php, and phpstorm would complain.

I think that the problems I was having previously might have been related to some DNS issues that seem to have been taken care of. Sometimes, it would work, and sometimes nothing I did seemed to make a difference.

Thanks again!

@pirog

This comment has been minimized.

Member

pirog commented Sep 26, 2016

Anyone game here to submit a PR to get this in our Pantheon docs?
https://github.com/kalabox/kalabox-app-pantheon/blob/v2.0/docs/users/tooling.md#xdebug

Might be good to flesh out the sublime text instructions as well @reynoldsalec

@pirog

This comment has been minimized.

Member

pirog commented Sep 26, 2016

Just for ref here is some working xdebug config for ST

"settings":
    {
        "xdebug":
        {
            "max_children": 32,
            "max_depth": 16,
            "path_mapping":
            {
                "/code/": "/Users/pirog/Desktop/apps/webspark/code/"
            },
            "port": 9000,
            "pretty_output": true,
            "url": "http://webspark.kbox/"
        }
    }

@pirog pirog added this to the v2.0.1 milestone Sep 26, 2016

@pirog pirog closed this Oct 3, 2016

@pirog

This comment has been minimized.

Member

pirog commented Oct 3, 2016

Alright! this should be in the pantheon docs now!

@bmcclure

This comment has been minimized.

Contributor

bmcclure commented Feb 6, 2017

Minor thing I came across: I didn't want to move my PhpStorm project up one directory, I wanted it to be in /code so that my .idea directory could be version controlled with the project.

I discovered that by going to Settings > Directories, you can click Add Content Root on the right of the directory list and add the "config" directory to the project separate from the /code directory. This then allowed me to map the path to prepend.php properly and Xdebug is working great!

@gravypower

This comment has been minimized.

gravypower commented Jul 19, 2017

For anyone who comes across this while googling, this video helped me get debug working with phpstorm.

@ashzade

This comment has been minimized.

ashzade commented Jul 20, 2017

I have it working as described here but prepend.php is triggered on every refresh if I'm debugging. Anyone know why?

@mortona42

This comment has been minimized.

mortona42 commented Aug 2, 2017

I mapped /code on the box to my site dir in Kalabox, but same as above.

@bradchesney79

This comment has been minimized.

Contributor

bradchesney79 commented Aug 9, 2017

Nice @pirog , for shoving in a random standalone PHP interpreter into PHPStorm-- I ended up with this:

https://stackoverflow.com/questions/44330629/how-to-load-old-php-versions-for-phpstorm-but-not-install-them-on-your-local/44335102#44335102

The use case was that a separate code base was using an old version of PHP completely separate from the nice v7.x PHP I had actually installed locally. This way you're able to pop a non-installed PHP version into PHPStorm to do whatever it does with the PHP executable it demands.

@ccharlton

This comment has been minimized.

ccharlton commented Sep 14, 2017

HTTPS support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment