Installing Xdebug for use with PHPStorm - php

I want to install a debugger for PHP for my MAMP environment on Mac OS 10.8.5, where I run PHP 5.5.3. I am looking at PHPStorm and Xdebug. I am doing my best to follow the instructions on the PHPStorm site.
Here are my steps:
1) Download the Xdebug extension compatible with your PHP version
$ su admin
$ cd /Applications/MAMP/bin/php/
$ git clone git://github.com/xdebug/xdebug.git
I understand that this installs Xdebug 2.3.2 (Release date: 2015-03-22)
2) Copy the extension file to your web server in a location that is accessible by the web server. I do not understand what this extension file is, so I have been unable to complete this step.
3) Add the following lines at the end of your php.ini file:
[Xdebug]
zend_extension="/Applications/MAMP/bin/php/xdebug/php_xdebug.h"
xdebug.remote_enable=1
xdebug.remote_host="localhost"
xdebug.remote_port="9000"
xdebug.profiler_enable=1
xdebug.profiler_output_dir="/Applications/MAMP/tmp"
Note the additional final line, suggested by this page.
4) Restart your web server
5) Check your installation
$ php --version
PHP 5.3.28 (cli) (built: Jan 23 2014 18:02:48)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
Not the right version of PHP. Trying again:
$ /Applications/MAMP/bin/php/php5.5.3/bin/php --version
PHP 5.5.3 (cli) (built: Sep 18 2013 14:31:13)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
There is no sign of "With Xdebug..."
What exactly should I do at step 2? Have I made a mistake at any of the other steps? Are there further steps that I am missing?

Related

Can't install Xdebug on PHP

Trying to install Xdebug so I can debug PHP with VS Code, followed the instructions of the page step by step, reference Xdebug wizard.
Download php_xdebug-3.1.6-8.1-vs16-x86_64.dll
Move the downloaded file to \xampp\php\ext, and rename it to php_xdebug.dll
Update C:\xampp\php\php.ini and add the line:
zend_extension = xdebug
Restart the Apache Webserver
To verify correct installation run cmd and type php -v, output should list Xdebug installed:
PHP 7.4.10 (cli) (built: Aug 18 2020 09:37:14) ( NTS DEBUG )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.10-dev, Copyright (c), by Zend Technologies
with Xdebug v3.0.0-dev, Copyright (c) 2002-2020, by Derick Rethan
Installation is trivial, I don't have cloned .ini files, I'm getting the right dll from the page, I'm restarting Apache, my renameing of the dll is right. I don't know what is going on, my output from cmd is:
C:\Users\User>php -v
PHP 8.1.13 (cli) (built: Nov 22 2022 15:49:14) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.1.13, Copyright (c) Zend Technologies
My PHP version is: 8.1.12
Also tried changing the ini file to
;zend_extension="c:\xampp\php\ext\php_xdebug.dll"
which is the actual path where the dll is located. Also my PHP is TS, so is the file it's downloading from the wizard. Any hints?
As #aynber said in a comment, semicolon is used for indicating comments and therefore the line
zend_extension="c:\xampp\php\ext\php_xdebug.dll"
is not processed

xdebug - timeout error and failed to load error with v2.2.5 and v2.5.5 for php 5.2.6/xampp/zend

I am usign xampp. php version 5.6.28. Thread Safe. opcache disabled.
xdebug version that comes with xampp is 2.2.5
I am running xampp in Windows 10 Enterprise 64 bit.
INI Settings are
[xdebug]
zend_extension=php_xdebug.dll
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
From the command line php -v I get
C:\Users\733283>php -v PHP 5.6.28 (cli) (built: Nov 9 2016 06:40:27)
Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright
(c) 1998-2016 Zend Technologies
with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
When I ran the application by enabling xdebug I get session time out error in some line of php code. When I searched I got the following. https://bugs.xdebug.org/view.php?id=1424. It is mentioned that it has been fixed in xdebug version 2.5.4 . From their download page I downloaded the xdebug version php_xdebug-2.5.5-5.6-vc11-x86_64.dll for php version 5.6.2. (They have mentioned both 2.5.4 and 2.5.5 works with php 5.6.2). I copied to the ext folder and modified the php.ini file as
zend_extension = php_xdebug-2.5.5-5.6-vc11-x86_64.dll
I tested this by running php -v from the command line. I got the following.
C:\Users\733283>php -v
Failed loading C:\xampp\php\ext\php_xdebug-2.5.5-5.6-vc11-x86_64.dll
PHP 5.6.28 (cli) (built: Nov 9 2016 06:40:27)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
When I tried their https://xdebug.org/docs/install I can see for php 5.6 the versions of xdebug 2.5 and 2.4 are mentioned. I tried both but got the same above output.
When I tried their testing page it says
Tailored Installation Instructions
Summary
Xdebug installed: no
Server API: Command Line Interface
Windows: yes - Compiler: MS VC11 - Architecture: x86
Zend Server: no
PHP Version: 5.6.28
Zend API nr: 220131226
PHP API nr: 20131226
Debug Build: no
Thread Safe Build: yes
OPcache Loaded: no
Configuration File Path: C:\WINDOWS
Configuration File: C:\xampp\php\php.ini
Extensions directory: C:\xampp\php\ext
PHP version 5.6 is not supported.
But their install page says xdebug version 2.5 works with php v5.6
I have also raised a issue in their website. https://bugs.xdebug.org/view.php?id=1678.
How to make it work?

Set default version of Php in CentOS 7

I have two versions of PHP in opt/remi folder php56 and php72
but when I php -v on cmd it shows:
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans
How to set default version to PHP 7.2?
I have two versions of PHP in opt/remi folder php56 and php72
how to set default version to PHP 7.2
SCL are designed for parallel installation so don't alter default version in base system
Once the collection is enabled, the version will be used
$ scl enable php72 bash
$ php -v
PHP 7.2.8 (cli) (built: Jul 17 2018 05:35:43) ( NTS )
If you want 7.2 to be the default version (base system) you should install it, according to Wizard instructions for "Default / single version" (and keep 5.6 as secondary version)
Change php cli version in Centos 7
First, find your php7, run phpinfo() and get path or you can do with other ways. for me, it is:
/usr/local/lsws/lsphp73/
then:
cd ~
. ~/.bash_profile
And:
alias php='/usr/local/lsws/lsphp73/bin/php'
Now:
php -v
PHP 7.3.13 (cli) (built: Dec 20 2019 16:02:35) ( NTS )
Create a file "/etc/profile.d/php.sh". Use pathmunge to add the path to your php bin you want as default on line one and save the file.
Example:
pathmunge /opt/remi/php73/root/bin
Reload your profile afterwards by logging in again.
Now if you do a which php and php -v you should see the following output in my case
[root#host etc]# which php
/opt/remi/php73/root/bin/php
[root#host etc]# php -v
PHP 7.3.4 (cli) (built: Apr 2 2019 13:48:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.4, Copyright (c) 1998-2018 Zend Technologies
with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v10.3.4, Copyright (c) 2002-2019, by ionCube Ltd.
This is the preferred way to accomplish this task using tools that are already supplied on a minimal install. This also allows scripts and commands to hit the correct php binaries when accomplishing other tasks. Commands like, pear, pecl, phar, php-config. You want your experience to be global when setting the default, otherwise you might wind up still getting version 5.6's tools when trying to install an extension or complete another task.
module enable php74
for your understanding:
cat /opt/remi/php74/enable
export PATH=/opt/remi/php74/root/usr/bin:/opt/remi/php74/root/usr/sbin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/opt/remi/php74/root/usr/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export MANPATH=/opt/remi/php74/root/usr/share/man:${MANPATH}

How to permanent enable PHP 5.4 on RHEL? (PHP 5.3.3 also installed on the system)

I recently installed PHP54 on a RHEL 6.5 server from the RHN Software Collection 1.1
The package has successfully been installed, and it needs to be mentioned there is an existing previous installed PHP version (5.3.3) on the servers which is the current enabled version.
I have checked several sites/forums/blogs and the suggestions are always the same, enable via scl (Setup and run software from Software Collection environment) and/or sourcing the file "/opt/rh/php54/enable". This seems to be a proper workaround to enable PHP54 as can be seen in the commands below.
But it is not permanent, as soon as I exit the shell the user who enabled PHP the changes are discarded.
NOTE: the commands has been run as "root" with the exact same behaviour shown in the following commands.
I've found references to add the source workaround into the ".bash_profile" of the user(s), but does not seems to be the best solution for me, I am wondering if someone else have already faced this problem and how it was solved.
Any suggestions?
[mithrandir#mordor ~]# scl enable php54 "php -v"
PHP 5.4.16 (cli) (built: Feb 4 2014 08:10:51)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
[mithrandir#mordor ~]# php -v
PHP 5.3.3 (cli) (built: Jul 15 2014 08:48:08)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
[mithrandir#mordor ~]# source /opt/rh/php54/enable
[mithrandir#mordor ~]# php -v
PHP 5.4.16 (cli) (built: Feb 4 2014 08:10:51)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
[mithrandir#mordor ~]# date
Fri Aug 29 12:29:35 MDT 2014
[mithrandir#mordor ~]# exit
logout
[me#mordor ~]$ sudo su -
[sudo] password for me:
[mithrandir#mordor ~]# php -v
PHP 5.3.3 (cli) (built: Jul 15 2014 08:48:08)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
[mithrandir#mordor ~]# date
Fri Aug 29 12:29:57 MDT 2014
It seems that in order to enable a package from the RH Software Collection the only way is by adding a script under "/etc/profile.d" and including the "source /opt/rh/php54/enable" command.
This is a link to RH devs blog, showing the solution. Be aware that it is for python33 but this workaround applies for software included on RHSC such as PHP54.
Permanently Enable a Software Collection
I implemented the solution and it is working. I hope this helps someone else.
Open a command shell window and check the PHP rpm package which is installed.
# rpm -qa | grep php
There should be an Apache php module. You need to download a rpm file which adds PHP to your Apache web server.
Use the website http://blog.famillecollet.com/post/2013/06/16/Red-Hat-will-provide-PHP-5.4-for-RHEL-6.
Here you find the hints how to permanently install PHP 5.4.:
# source /opt/rh/php54/enable
# php -v
PHP 5.4.14 (cli) (built: May 23 2013 07:42:19)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
If you want PHP 5.4 permanently enabled and your /etc/conf.d/ directory has the conf file for PHP 5.4 (possibly php54-php.conf) in it, you can comment out the lines in /etc/conf.d/php.conf that load the PHP 5.3 modules:
<IfModule prefork.c>
LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule worker.c>
LoadModule php5_module modules/libphp5-zts.so
</IfModule>
You can also delete /etc/conf.d/php.conf or rename the file to remove the .conf extension so that it isn't loaded by /etc/conf/httpd.conf. After doing either of these, restart Apache to load PHP 5.4.

how to update native php 5.3 mac installation with installed brew php 5.4 installation?

I am trying to work on laravel framework, i got an error for which i needed php5.4+. earlier i had installed php, apache and mysql somehow which came with mac.
when i check the versions i get as below:
$ /usr/local/Cellar/php54/5.4.19/bin/php -v
PHP 5.4.19 (cli) (built: Sep 17 2013 21:14:22) (DEBUG)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
$ php -v
PHP 5.3.15 with Suhosin-Patch (cli) (built: Aug 24 2012 17:45:44)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
right now php5.3 gets displed on phpinfo(), how to make apache use php5.4?
if which php still gives /usr/bin/php, add this line to the end of your ~/.bashrc (or ~/.zshrc if you use ZSH)
export PATH="$(brew --prefix)/bin:$PATH"
Also see https://github.com/josegonzalez/homebrew-php#installing-multiple-versions
EDIT
For Apache
LoadModule php5_module /usr/local/opt/php54/libexec/apache2/libphp5.so
php5.3, php5.4, php5.5
http://php-osx.liip.ch/
PHP 5.5
http://mac.tutsplus.com/tutorials/server/upgrading-the-native-php-installation-on-os-x-mountain-lion/

Categories