0

My stack is

nginx + php php-fpm + xDebug + PHPStorm

I have put at the very beginning of my index.php

echo "foobar";
exit;

and placed a breakpoint on the very first line.

If I run the script from PHPStorm everything is as expected: execution halts on the first line.

If I run the script by visiting my website with Chrome I just see foobar on the browser (while what I expect is the site just displaying nothing, and PHPStorm halted on the first line, the one with the breakpoint.)

What would I have tried/done so far:

configured php.ini

zend_extension="/absolute/path/to/xdebug.so"

xdebug.mode = debug
xdebug.start_with_request = trigger
xdebug.discover_client_host = 1
xdebug.client_port = 9003

On PHPStorm:

Settings > PHP > Debug port: 9003 - Can accept external connections: YES
Settings > PHP > Servers:
    Servers list: www.example.com
    Server settings for www.example.com
        Name: www.example.com
        Host: /absolute/path/to/www/www.example.com/html
            (inside html is index.php that is the first script executed)
        Port: 443
        Debugger: Xdebug
        Project files: (a single entry)
            /absolute/path/to/www/www.example.com/html

Chrome with xDebug extension have the debugger activate when I load the page (green bug icon)

1

2

3


EDIT

Maybe this detail may be relevant to solve the solution.

When I set a breakpoint in PHPStorm the line is highlighted but no red dot appears on the left. See image...

4

2
  • you'll need to do php_info() in your i.php to ensure xdebug is activated. Also you might need to check your extension to ensure the KEY is set to PHPSTORM Commented Aug 10 at 8:52
  • What does PHPStorm's XDebug Validator (see jetbrains.com/help/phpstorm/…) tell you about this? Commented Aug 11 at 13:28

2 Answers 2

1

In order for debugger to recognize what incoming request it should start its session on, you need to specify xdebug.idekey value in php.ini. Generally it is PHPSTORM , but can be anything you prefer.

After that, you should pass a query parameter XDEBUG_SESSION_START=PHPSTORM in the request you wish to debug, which will initiate debugging session.

Alternatively (if you want to skip above hassle) you can select Break at first line in PHP scripts option from Run menu in PHPStorm - that will start breaking at the beginning of the file that is ran; after that you can Continue the execution until the next breakpoint.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you. Unfortunally the solution provided doesn't solve the problem. (I restarted php-fpm off course) - I added another detail to my question that may be relevant.
Try putting 9000,9001,9003 in Xdebug port - this will allow to track those ports for debugger. I doubt you need to put port 443 for your Server configuration - this is a local installation, is it not? For local debugging generally it's advised to skip SSL setup and work straight on port 80 (in NGINX server setup). In my setup I set xdebug.client_host = 127.0.0.1 and xdebug.client_port = 9001. Try triggering Break at first line in PHP scripts to see if debugging session even begins.
solved!! The cause of the problem was another one. But thank you for your effort in helping me!
0

The issue was due to the peculiar configuration on my Mac:

the website I'm working on quite small so it's good for me to have the same setup on both production server and local server

when I'm working locally I open /etc/hosts and I insert (or uncomment) the line

127.0.0.1 www.example.com

(when I want see the real production website I just comment the line and clear the dns cache)

From a PHPStorm point of view I'm debugging a remote server

I just re-configured it with this assumption and now it works

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.