Trouble debugging using PhpStorm when having command line inputs - php

I am trying to debug my php script using PhpStorm and xdebug.
See my xdebug configurations below,
As for the breakpoints, I have added two of them to a simple script which reverses an array,
I debug using the default debug configurations,
The first breakpoint works fine and I am able inspect the variables. But I cannot seem to move the control to the second breakpoint. This is how my screen looks after moving from the first breakpoint and executing line num 14. Line 14 takes in an input from the command line,
So, I tried entering inputs in the console, (can see the 3 i entered)
The debugger looks blank,
I am getting myself familiar with php and xdebug, so I guess the problem should be something trivial. What do you think?

Related

Xdebug in PhpStorm doesn't show local variables

I trying install Xdebug on PhpStorm + OpenServer. Everywhere php v7.2. I tried several times to install different version of Xdebug.
There are my settings:
Also have Xdebug helper in Chrome, but variables still doesn't display.
If I enable break at first line flag, phpstorm show me this, but if I press "step into" it disappears.
I had the same issue with console application. Try insert somewhere before function you watching:
ini_set('xdebug.collect_vars', 1)
Or execute it in evaluation window.

XAMPP WordPress PHP VSCode Xdebug no locals

I use WordPress with a local XAMPP server.
To debug my PHP code I use Xdebug and Visual Studio Code, but it doesn't work as I expect. When I stop the execution on line 191 and step over to line 194 I want to see the values of my two local variables $html and $rmcounter in the upper left corner at VARIABLES->Locals but there is nothing.
When I proceed with step over until I leave my rm_deug_test() function I see shortcodes.php and then everything works. I see the Locals in the upper left corner and I can hover over e.g. $tag and I see the value of this variable.
What should I do to see the values of the variables of my rm_debug_test() function?
In the meantime I found a solution that could be of interest to other programmers using wordpress xampp xdebug php and visual-studio-code: I changed the php.ini file in the folder xampp/php. I had only to disable opcache. I changed opcache.enable=1 to opcache.enable=0. Now debugging with visual-studio-code shows all local variables as soon as they are created when I assign a value.

How Can I see steps of running codes in phpstorm?

I have a problem in my PHP codes I cant find that. because dont display any warning or error and redirect to the main page of my website project and after many test couldnt find problem.
I want to see steps of running the code for example:
get values of $click and $usercode variables===> redirect to request_change.php and run mysql_query with value="select * from users where userid=65643"==> get $username ==> and else...
I can see some running steps by debugging but not exact that I Want and display many error about finding some directories in require_once function but while my webpages display and process information right by wamp.
Is any way to debugging same as that by Phpstorm or any other programs?
OR
How can I run My php code in phpstorm step-by-step and line-by-line??
Update:
I configured phpstorm for debugging but Just I can use debug and select one of page to debug.I checked all the settings steps that were done correctly But The step by step debug buttons is'nt active such as stepOver and step intro and else... In addition, after debugging the codes, the error : PHP Warning: include_once(): Failed opening '.\dref.php' for inclusion (include_path='.;C:\php\pear') in C:\wamp\www\srn\mrt\req_v.php on line 260
is displayed, while the same code works well in the wamp by Firefox
What should I do to solve this problem?
One of the most powerful and useful tools any developer could have is a debugger. I use xDebug myself. With it you can step through a program during execution and watch each method call, every variable value change, and every action the program does. With PHPStorm it is typically very easy to enable / use xDebug. This would be my recommendation for troubleshooting the issue you have.
References:
https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html
https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm
https://confluence.jetbrains.com/display/PhpStorm/Xdebug+Installation+Guide

Symfony console outputs "i" and commands do not work in Netbeans

I recently updated my composer.phar file to upgrade all of my dependencies, and after that the , the Symfony2 commands in Netbeans no longer works. When I select Run command, an error message says:
<There is no command available (perhaps error?)>
In the output window, it looks like the comand list is being generated, except for one problem
"/usr/bin/php" "/home/web/Project/app/console" "--ansi" "list" "--xml"
i<?xml version="1.0" encoding="UTF-8"?>
<symfony name="Symfony" version="2.5.0 - app/dev/debug">
<commands>
Notice that the second line begins with "i". I think this is the cause of the problem and am not sure how to get rid of it. When I open up a console window, all of the commands work, but each command has the output begin with an i.
I have an older test project, and the commands still work in that so this error must have happened when I updated composer.
I just realized this is a bigger issue. The i is outputted on all pages so none of the pages appear correctly anymore since it begins with i instead of the tag.
Anyone come across this before or know how to prevent symfony from generating the i?

xdebug on OS X partially working (e.g., prints stack trace in terminal but not browser).

I'm trying to get xdebug working on my Mac. I'm using OS 10.6 with the built-in versions of Apache (2.2.1) and PHP (5.3.8). I followed the "tailored installation instructions" on the xdebug website, which basically consisted of these steps:
Build xdebug (version 2.1.3) from source
Move xdebug.so to /usr/lib/php/extensions/no-debug-non-zts-20090626
Add to php.ini:
zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
Restart the webserver.
From what I understand, that should be it. I know most people use xdebug with an IDE like PHPEclipse, but it doesn't sound like that's necessary just to get debugging output on the page. And a lot of old instructions involve installing MAMP, but it looks like that's no longer necessary.
Signs xdebug is working: When I run php -m and phpinfo() I get the expected information on xdebug. In scripts I'm able to call functions like xdebug_is_enabled() (returns 1) and xdebug_get_function_stack() (returns the stack).
Ways xdebug is not working: The main reason I installed xdebug was to get a stack trace when there's an error, and that's not happening. According to this documentation page, I should get a stack trace as long as display_errors is set to On in php.ini, (which it is). I've tried code that should evoke a warning (e.g., echo(hello)) as well as code that produces a fatal error (e.g., $x->awesomefunction() when $x isn't an object). Neither one produces any xdebug output, and the fatal error just causes the page to die silently. The test code given in the documentation I linked to also produces nothing.
UPDATE: It turns out that if I run a script with a fatal error from the terminal, I do get a stack trace from xdebug. However, it's still not showing up when I run the script from a browser
Also, regular error reporting is now broken: Previously, I'd get error output by including the commands:
ini_set("display_errors","1");
ERROR_REPORTING(E_ALL);
Now, putting those lines in my script doesn't produce any error reporting either. (in the browser. It does cause errors to be shown when I run the script from the terminal.)
So, what's wrong here? Did I leave something out of the xcode installation? Do I have a setting hanging around somewhere else on my system, suppressing errors? I've tried everything I can think of, but I'd be happy to test any ideas you have.
If it is working on console and not on browser, it's probably a xdebug configuration issue.
I'm not a Mac user, but on Ubuntu there are 2 different php.ini files, one for console and one for apache. If that's the case for Mac also, you can check if xdebug is enabled and properly set up in both php.ini files.
Also you can check the xdebug settings mentioned in the guide.
After several more hours of thrashing, I discovered that one of my test files actually was including another file that set display_errors to 0. The other test file was straight off of the xdebug site, but I think that at the time I was using it I'd introduced some other config error that prevented it from working properly. I'm truly embarrassed! Let this be today's object lesson in the importance of systematic, repeatable tests during debugging. On the bright side, xdebug is now working like a peach.
To summarize, the series of steps that worked was:
Build xdebug (version 2.1.3) from source
Move xdebug.so to /usr/lib/php/extensions/no-debug-non-zts-20090626
Add to php.ini: zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
Add to php.ini: display_errors = On
Restart the webserver.

Categories