How to ensure XDebug is installed correctly? - php

I've downloaded the PHP version of Netbeans from here:
https://netbeans.org/downloads/
And I've pasted the output from phpinfo(); here:
https://xdebug.org/wizard.php
I followed their instructions:
Download php_xdebug-2.5.0-5.6-vc11.dll
Move the downloaded file to .\ext
Edit C:\php\php.ini and added the following line to the bottom of my .ini:
zend_extension = .\ext\php_xdebug-2.5.0-5.6-vc11.dll
Restart the webserver (IIS 7.5)
I copied that line and pasted it at the very bottom of my php.ini file. Does it belong somewhere else? Under the [PHP] section?
When I run NetBeans, I've opened my project and went to Properties -> Run Configuration -> Project URL and updated that to the correct path (http://localhost/myApplication/).
When I press Ctrl-F5 (Debug Project) a browser window opens with the following in the address bar:
http://localhost/myApplication/?XDEBUG_SESSION_START=netbeans-xdebug
So it looks like it's installed correctly, but if I set a breakpoint in my index.php file it doesn't trigger. I've tried setting other breakpoints throughout the software and those don't trigger, either.
I noticed in Netbeans, this progress bar just moves back and forth:
Should it be doing something?
EDIT Just doublechecked phpinfo(); and now I see this:
Zend Extension: 220131226
Zend Extension Build: API220131226,TS,VC11
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
report_zend_debug: on, on
So it seems like it's installed... What am I doing wrong?
And here's a screenshot of phpinfo();: https://i.stack.imgur.com/noSx4.png

Related

How to enable php-debug in Atom?

I have installed php-debug in Atom + its IDE dependencies. When I set a breakpoint the debug view opens saying The debugger is not attached, but when I am trying to do so it seems as if Atom doesn't recognize I have php-debug package installed and asks me to install a debugger.
I read on some places there is a toggle debugging setting on the package, but I can't see that option.
I'm using Atom 1.27.0 and PHP 7.2.4:
PHP 7.2.4 (cli) (built: Apr 12 2018 02:49:03) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
with Zend OPcache v7.2.4, Copyright (c) 1999-2018, by Zend Technologies
I could provide Xdebug configuration but seems like the problem is on Atom itself? Did anyone have this problem?
very simple
Download xdebug from https://xdebug.org/download.php, TS version for Apache
Copy it to php/ext directory
Copy below text in php.ini below all other extensions
zend_extension="D:/wamp/php/ext/php_xdebug-2.6.1-7.2-vc15-x86_64.dll"
[xdebug]
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1 # Not safe for production servers
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true
Restart Apache and Find "xdebug" string in <?php phpinfo()?>
Install atom-debug_ui, php_debug
Package > PHP Debug > Toggle
Apply break-points and Run a PHP file from browser and that's it.
If it ask for paths remote http://localhost/DIRECTORY_PATH_TO_PHP_FILE
and local is directory path to PHP file.
I had the very same message few days ago …
Breakpoint were acually hit, I could see this because of the browser's tab loading icon, but nothing was happening on Atom user interface. All I could do was clicking stop or detach buttons which caused xdebug to end session and terminate browser tab load.
Using PHP7.2.7, Xdebug 2.6 (Docker php-fpm-alpine); Atom 1.26.1 x64
TLDR; PHP-debug extension couldn't process the "Path mappings" value I entered in the configuration panel.
Opening the dev console in Atom allowed me to spot an error accuring as the debugging session gets initiated in PHP Debug extension.
Atom Debug (PHP Debug) Session initiated
logger.js? [sm]:43 Atom Debug (PHP Debug) [TypeError: Cannot read property 'endsWith' of undefined
at Object.exports.generatePathMaps (/hom…]0: TypeError: Cannot read property 'endsWith' of undefined
at Object.exports.generatePathMaps (/home/me/.atom/packages/php-debug/lib/helpers.js:80:34)
at /home/me/.atom/packages/php-debug/lib/engines/dbgp/debugging-context.js:112:37
…
This led me to read at the Github repository and quickly figure what was going on.
All I had to do was changing the "Path mappings" text field value I erroneous filled in the first place. The text field expects a JSON string, as we can see HERE, the path mappings should be an iterable/array made of objects. It has to loook like this:
[{"localPath":"/home/me/projects/my-project","remotePath":"/var/www/my-project"}]
Add more mapping objects if you have more than one project. Note that this setting is reflected in ~/.atom/.config.cson
This fixed the issue, the debug view do not pop anymore saying there is no debugger attached.
I also had this problem, with Atom 1.53.0, PHP 7.3, and XDebug 2.9.8. I could tell from netstat that XDebug was connecting to Atom, but there was no activity in the PHP Debug tab, and no messages in the Console or PHP Console to give a hint of what was (or wasn't) going on.
Unlike Stphane, I didn't have any path maps defined. But taking a hint from his answer, I clicked on the "Path Maps" button in the PHP Debug tab. Then a series of error dialogs popped up, which I was able to solve one at a time.
In my case, the errors all happened because the project I'd checked out had some Unix symlinks in it, which Windows didn't know how to interpret. I solved them by removing the symlinks, and copying into their place copies of the files and directories they'd been pointing to. After that, the PHP Debug pane worked as expected - although the Debugger still says "No debuggers installed".
Atom Told me Debugger is not Attached but i made it work.
i saw atom php-debug tutorial but had problems like debugger is not Attached.
i want to share the configurations which that tutorial didn't includes:
Xdebug.ini autostart and idekey
first in the tutorial xdebug config. configs it to run automatic.
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1 # Not safe for production servers
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true
but its getting debugger run for every request. so you can make it off as this:
xdebug.remote_autostart=false
after that you have to tell debugger to send debug to atom`s api by appending this to xdebug config:
xdebug.idekey=xdebug-atom
if you use php-fpm, you have to reload it additional to restarting your http-server:
sudo systemctl reload php-fpm.service
Browser Extension with correct idekey parameter
after that install the browser plugin which attach a cookie to tell xdebug to made this request debuggable.
if your plugin hasnt Atom config,
in your browser extention preferences make this:
IDE key: xdebug-atom
Atom 2 plugins Enable and disable atom-ide-ui-feature-debug
and after that in Atom editor itself:
after installing atom-debug-ui and php-debug .
from Edit -> Preferences -> Package
select package atom-ide-ui package settings.
section Enable Features -> Enable Debugger
make it Never enabled .
like this:
https://github.com/gwomacks/php-debug/issues/310#issuecomment-419751273
True Break Points
now from Packages -> Debug -> Toggle Debugger
another note is when you want to make break point in atom. there are 2 types of break point. Big blue Dots and small blue dots.
only small ones work for debugger.
like here suggested:
https://learnwithdaniel.com/2019/06/atom-php-debugger/
Make remote path and local path identical
after setup request from browser. and Atom Asks you remote/local path.
make them identical

Is ioncube loader working in my case?

I used Putty to install ioncube loader. Used php -v to check and it shows
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v5.0.19, Copyright (c) 2002-2015, by ionCube Ltd.
However, I inserted a page with the following code in my website to check:
<?php
phpinfo();
?>
but it doesn't show that ioncube loader is enabled.
I also used:
<?php
echo var_export(extension_loaded('ionCube Loader') ,true);
and it returned false.
My Server API is CGI/FastCGI so I have already included
zend_extension = /usr/local/ioncube/ioncube_loader_lin_5.4.so
in the following file /etc/php5/cgi/php.ini
I wonder if it's really working or not?
A common mistake over time is having a different major PHP version for CLI and the web server, so perhaps your website does not use PHP 5.4. Another gotcha is using a different php.ini for website and cli, or having a php.ini in the same location as a web request that, on a cgi system, overrides that main php.ini. The web server software or fastcgi pool in this case may also need to be restarted.
First of all, go to your terminal and type which php this will show you the directory of the particular php.ini file that is currently being used by the php installed on your computer.
Open the php.ini file and make you have added this line zend_extension = /usr/local/ioncube/ioncube_loader_lin_5.4.so before any other Zend extension is loaded on the php.ini file.
Also note that the ionCube loader ioncube_loader_lin_5.4.so will only for PHP 5.4.* only.
Make sure you have copied the file into the directory you stated, you can verify by tying cd ~ and then sudo find /usr/local/ioncube/ioncube_loader_lin_5.4.so to make sure the file is situated there, if it is the terminal will return the file name showing it found it.
Now save the changes made on your php.ini file and run the command sudo apachectl restart (for Apache servers) to restart your server.
Test with php -v from your terminal again.
Hope this helps.

Phalcon module loaded but still class can't be found

I have installed Phalcon on my vServer and it seems to be loaded,
but if I try to run website I get an error
PHP Fatal error: Class 'Phalcon\\Config\\Adapter\\Ini' not found in /home...
php -v
PHP 5.6.10 (cli) (built: Jun 11 2015 08:33:51)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
I followed the instructions on Phalcon website.
If I list php modules using php -m Phalcon is listed, I don't have
any errors, just don't know why it's not working!
Also, Phalcon is not listed on phpinfo(); page.
looks like you changed the config for the php console client but that config is not the same for the php module in apache.
Review what config is being loaded for apache module
When installing phalcon in order to get the extension working make sure to restart nginx / apache2, and if you are running PHP as a module php5-fpm service as well.
$ sudo service nginx restart
$ sudo service php5-fpm restart
I encountered the same problem and the reason is that I recompiled php with source code but not recompiled phalcon again after that. I solved that by compiling phalcon again with the correct phpize.
Sometimes when phalcon is installed, it creates a separate .ini file for itself and adds the extension therein. This is common in mac and linux OS. In such situation, type php --ini on the terminal. You should see an out put similar to the following...
Configuration File (php.ini) Path: /usr/local/etc/php/5.6
Loaded Configuration File: /usr/local/etc/php/5.6/php.ini
Scan for additional .ini files in: /usr/local/etc/php/5.6/conf.d
Additional .ini files parsed: /usr/local/etc/php/5.6/conf.d/ext-mongodb.ini,
/usr/local/etc/php/5.6/conf.d/ext-phalcon.ini
As you can see, phalcon created the /usr/local/etc/php/5.6/conf.d/ext-phalcon.ini file.
SOLUTION:
Open the file using sudo nano /usr/local/etc/php/5.6/conf.d/ext-phalcon.ini, copy the line in which the extension is loaded and paste in /usr/local/etc/php/5.6/php.ini if you are using XAMPP, copy the line to /Applications/XAMPP/xamppfiles/etc/php.ini Restart your server and check if that works.

Netbeans / XDebug broken breakpoints

I am setting up xdebug with netbeans for my PHP application, hosted on a local xampp installation (Windows 7)
The installation and command line tests were successful and working correctly according to the netbeans / xdebug documentation. However, when I add a breakpoint in my code, it appears as a "broken" breakpoint no matter where I place it in the code. When I run the app w/ debugger, it fails to stop at these broken breakpoints.
I've done a lot of searching but haven't come across a good explanation for this, anyone out there have suggestions?
Thanks
Solution 1:
You need to configure the correct mapping between project source code and Xdebug output. you coudl do it here:
Project Window -> right click on project name -> Properties -> Run Configuration -> Advanced -> Path mapping
Solution 2:
Check in php info if xdebug is properly configured. You could check it by phpinfo() in empty php file and run it in browser:
<?php
phpinfo();
Try to find:
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
Then in php.ini (you could check the location of this fiel in phpinfo() add this section:
[xdebug]
xdebug.remote_enable = On
xdebug.profiler_enable = On
xdebug.profiler_enable_trigger = On
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/xamp/tmp"
xdebug.remote_handler=dbgp
xdebug.remote_port=9100
xdebug.remote_host=localhost
(make sure if this directory c:/xamp/tmp exists)
Then in netbeans in:
Tools -> Options -> PHP -> Debugging
Set:
Debugger Port: 9100
and select "Stop at First Line"
Save it and debug the applictaion it should work fine now.

PHP Zend Debugger configuration

Hi i am new to php, I currently learning php using eclipse. I know i have to install the zend debugger my php.ini store at c:windows i had added in these line:
[Zend]
zend_extension=c:/php/ext/ZendDebugger.dll
zend_debugger.allow_hosts=127.0.0.1
zend_debugger.expose_remotely=always
zend_debugger.connector_port=10013
but on command prompt i tried php -m it shown that i never install zend debugger. I not sure where goes wrong I check phpinfo also never show any zend information.
I had lots of problems making the debugger work. Now I'm using the ZendServer CE which is free and the configuration is a lot easier.
Also I use Eclipse + PDT, downloaded from Zend Site.
This should work right out of the box. Why not using ZendServer? you get everything you want in a package.
On a browser go to:
http://localhost/?phpinfo=1
look for "Loaded Configuration File"
and take a note of the path
Now open a DOS prompt window (Start > Run > (type) cmd)
and at the command line type
c:\path\to\your\php\php.exe -r phpinfo(); |more
(press CTRL+C to break)
Again look for:
"Loaded Configuration File"
and take a note of this path.
It could be that you are using a different php.ini for your webserver and for the CLI version.
You will need to add the config changes to both php.ini files or put the config in a file called zend.ini and place that in the folder that is mentioned in your phpinfo output under:
"Scan this dir for additional .ini files"
I have experienced the same thing when I was using thread-safe PHP on Windows.
Up to date versions of the Zend Debugger no longer support running in thread-safe flavors of PHP on Windows. Switching to a non-thread-safe (a.k.a nts) flavor of PHP fixed this issue for me.
See here: http://forums.zend.com/viewtopic.php?f=59&t=1918#p13729

Categories