I am searching the way to debug php scripts. In internet i found information that i can do that with MacGDBp + XDebug.
When i'm trying install using PECL in Shell:
sudo pecl install xdebug
The next error have been occured:
downloading xdebug-2.4.0.tgz ...
Starting to download xdebug-2.4.0.tgz (264,832 bytes)
.....................done: 264,832 bytes
76 source files, building
running: phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
Help me find the way to solve that problem.
XDebug is available by default. Just enable it by
1) sudo nano /etc/php.ini (or sudo cp /etc/php.ini.default /etc/php.ini first if the file doesn't yet exist)
2) Add these lines at the end (verify the path with ls ls /usr/lib/php/extensions/)
[Xdebug]
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"
3) Restart apache using sudo apachectl restart
4) Verify by php -m | grep xdebug
Mike Chamberlain's excellent response almost got xdebug working with NetBeans using Mac OS Sierra 10.12. Only two changes required:
In step 2, after
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so"
also add
xdebug.remote_enable=1
This was necessary because the precompiled .so file has xdebug remote access disabled. NetBeans and other tools need it to be enabled.
For debugging using xdebug i used the following steps
For installing php72 I installed using brew with the following command:
brew install homebrew/php/php72-xdebug
I added the following command to the bottom of the php.ini file:
zend_extension=/usr/local/Cellar/php72-xdebug/2.6.0/xdebug.so
Note: if you need to search for a version of xdebug with brew use:
brew search xdebug
Related
So macOS High Sierra 10.13 now comes with PHP 7.1. While configuring Apache I also created a new /etc/php.ini from the /etc/php.ini.default file, made sure to check that is was being loaded by PHP after restarting Apache, however the version of Xdebug extension that ships with macOS 10.13 doesn't seem to load or show up when you run phpinfo();
My php.ini is definitely being loaded:
$ php -i | grep php.ini
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
Here's what my /etc/php.ini looks like where I configure Xdebug:
[xdebug]
zend_extension = "/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so"
xdebug.remote_enable=on
xdebug.remote_log="/var/log/xdebug.log"
xdebug.remote_host=localhost
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
[Update, fixed that typo here...]
However, Xdebug doesn't load and checking php -i give no results:
$php -i | grep xdebug
PHP Warning: Method xdebug_start_function_monitor() cannot be a NULL
function in Unknown on line 0
PHP Warning: xdebug: Unable to register functions, unable to load in Unknown on line 0
Segmentation fault: 11
And yes, the path to the file is correct:
$ ls /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so*
This used to work on PHP 5 so I hope someone can help me and anyone else in future struggling with this issue.
When I check my apache log I get the following error:
Failed loading /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so: dlopen(/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so, 9): Symbol not found: _xdebug_monitored_function_dtor
Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
Expected in: flat namespace
in /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
I'm not making progress in terms of find out how I can resolve this error:
Symbol not found: _xdebug_monitored_function_dtor
Ok so I finally got it running myself it works perfectly! I'm assuming that the xdebug binary that comes with macOS High Sierra (found under: /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so) is not compatible with PHP7's new Zend engine.
So I downloaded the latest source from the xdebug website and did the following:
Installed autoconf with brew;
Run phpize to configure the build for the new Zend engine;
Run ./configure
Run make
Now the new binary is under modules/xdebug.so
However macOS System Integrity Protection (SIP) will prevent you from overwriting the xdebug.so under /usr/lib/php/extensions/. I didn't want to disable this so I created a new directory path under /usr/local/lib/php/extensions/ and copied the new binary to this location. I'm not sure if this directory is the best place to put it or if this is bad practice but it worked for me.
Finally I reconfigured my php.ini to use the new binary and everything worked perfectly!
In order to install it you have to have xcode command line tools.
So you need to run:
xcode-select --install
Then you need to install autoconf:
brew install autoconf
Then you have to download the code from here.
After that you have to run in the folder of the source code:
phpize
./configure
make
sudo cp modules/xdebug.so /usr/local/php/extensions (if the directory doesn't exist go and create it)
And finally inside php.ini add
zend_extension=/usr/local/php/extensions/xdebug.so
After that you can enable xdebug inside php.ini and restart apache
sudo apachectl restart
you made a typo in "zend_extention". this should be zend_extension.
and i think the full path is unnecessary
zend_extension=xdebug.so
should be enough
If you have brew installed with multiple PHP versions i.e. 7.1, 7.2 and 7.3 on Mac OS X mojave, you can to do the following:
Install autoconf with brew brew install autoconf.
Change to the PHP version that you want Xdebug on, run brew unlink php#7.1 && brew link --force --overwrite php. This will switch from PHP 7.1 to PHP 7.3.
Download the latest Xdebug source from xdebug website.
Extract the Xdebug tar and navigate to extracted directory, where you'd see all the files.
Run phpize to configure the build for the new Zend engine.
Run ./configure.
Run make.
Xdebug extension xdebug.so gets compiled in modules directory.
Create a new directory path under /usr/local/lib/php/7.3.1/extensions/ and copy xdebug.so to this location. Here, 7.3.1 is the current version that I switched earlier, change this to match your PHP version.
Open php.ini in an editor and enter
zend_extension="/usr/local/lib/php/7.3.1/extensions/xdebug.so" then save the change.
Run php -v and it will show Xdebug has been configured correctly.
If you want to configure Xdebug on another PHP version then just repeat from step 2 all the way to 11. As mentioned in earlier post, this way you don't need to disable/enable System Integrity Protection on Mac OS X.
For anyone arriving late at this party, the initial attempt in the question seems to work just fine in macOS 10.13.6
Hello for everyone that got error trying to install xDebug on Mac.
error: unknown type name 'uint64_t'
There are files in your local/bin/include that causes this error. By removing them you get rid of the error. Though, you might have to reinsatall brew.
https://github.com/cython/cython/issues/2009
I've just installed the latest XAMPP for PHP 5.6 from the official website, and I need to enable Xdebug, I find that the file php_xdebug.dll exists in the C:\xampp\php\ext , but there is no [XDebug] config at all in the php.ini and I have no idea how to make it work. It should be installed by default and pre-configured, we need just to uncomment the xdebug config in php.ini but it's not the case. I even tried to install it again using PECL commmand pecl install xdebug but I get the following error :
pecl install xdebug
downloading xdebug-2.5.0.tgz ...
Starting to download xdebug-2.5.0.tgz (267,640 bytes)
.........done: 267,640 bytes
ERROR: failed to mkdir C:\php\pear\docs\xdebug\contrib
And in PHPStorm when I choose to add the interpreter by selecting the php.exe in the XAMPP directory, it says Debugger : Not installed too.
I re-installed XAMPP, but I still have the same problem.
Thanks in advance.
For more details, you can find a tutorial that explains step by step procedure
php-debugging-with-xdebug-atom-and-xampp
As per this tutorial please follow these steps its works like a charm:
Steps to Install Xdebug:
Download xdebug-2.4.0.tgz
Unpack the downloaded file
# navigate to the downloaded file
$ cd ~/Downloads
$ tar -xvzf xdebug-2.4.0.tgz
$ cd xdebug-2.4.0
run phpize
$ phpize
# example output
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
#Error possibilty
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
#In the above error case you need to install autoconf using below command(MAC) and rerun phpize
$ brew install autoconf
The phpsize command is used to prepare the build environment for a
PHP extension.
Configure it by run:
$ ./configure
run make
$ make
A successful install will have created xdebug.so file.
Steps to Configure Xdebug:
A successful install will have created xdebug.so and put it into the PHP extensions directory.
You must copy this file to XAMPP php extension directory for that
run:-
$ sudo cp modules/xdebug.so /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20160303
Finally update /Applications/XAMPP/xamppfiles/etc/php.ini and add
the following lines to it
[Xdebug]
zend_extension = /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=On
xdebug.remote_port="9000"
xdebug.profiler_enable=0
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true
Restart Apache using XAMPP’s manager-osx
Congratz! You have completed!! To verify you successfully installed & configured XDebug, open the XAMPP phpinfo.php file in a web browser, for example, http://localhost/dashboard/phpinfo.php.
Search for XDebug section in PHPInfo details. If it exists, you successfully have done your installation
OR
In another browser window or tab, open https://xdebug.org/wizard.php and copy the phpinfo.php page content in the first window or tab and paste it into the textbox on the xdebug.org page. Then submit for analysis, it will give a summary of your installation status.
Safest was is to use XDebug wizard that will give you step by step instructions on how to install on your own machine. Then update your php.ini (tune to your needs)
Note: Wizard will give you instructions for what SAPI it receives phpinfo() contents from. So if you fill CLI phpinfo() output you will get instructions for your PHP CLI. If you paste phpinfo() from a server page you will get instructions for that.
First copy your phpinfor() content form. paste the [xdebug wizard][1] [1]: https://xdebug.org/wizard. then download the xdebug.dll. after that follow this steps
Remove the exists php_xdebug.dill and paste the xampp\php\ext\php_xdebug.dll
update the php.ini like this
[Xdebug] zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_enable=1 debug.remote_autostart=true
I found a solution for xdebug not working even after xdebug has been installed in NetBeans +xampp here. The idea is you have to use all the settings for php.ini mentioned here and not just the usual ones mentioned in forums.
I am trying to make postgresql work with apache on my Mac OSX. I use homebrew to manage all my dev features, so I replace the default php version provided by apache and download a homebrew version, this part works really fine. The problem is when I want to install the postgresql extension..
I have done this :
brew install postgresql
brew install php55 --with-postgresql
brew install php55-pdo-pgsql
And then edit the /etc/apache2/httpd.conf file to replace LoadModule php5_module libexec/apache2/libphp5.so by LoadModule php5_module /usr/local/opt/php55/libexec/apache2/libphp5.so.
Then when I exec the phpinfo() command, I can't see the postgresql extension installed in the PDO section. I only have this :
If anyone can help ;) Thank you all !
Possible solution :
- First install all packets like this : brew install postgresql php55 php55-pdo-pgsql
- Then brew reinstall php55 --with-postgresql
And it works.. I did this before (maybe not the same order) and it didn't work, I do not know why it works now !
Solution
When you watch the phpinfo() result, you should see something something like Loaded Configuration File and *Scan this dir for additional .ini files *. The thing is there is a global php.ini file and a .ini file per extension you install.
The value for *Scan this dir for additional .ini files * is where the .ini file for the extension must be located. So just need to create a ext-pdo_pgsql.ini and load the extension with extension="path to your/pdo_pgsql.so" (mine was /usr/local/opt/php55-pdo-pgsql/pdo_pgsql.so).
And for the installation just need brew install php55 php55-pdo-pgsql postgresql
Run php -m | grep pgsql to know if pgsql exists
Follow the example in this answer. Jump to note if you have a problem with the instruction there corresponding to number 4 here.
Enter ./configure --with-pdo-pgsql="path to postgres" and return. Mine is at "/usr/local/bin".
Enter make && sudo make install and return.
Add the extension to php.ini with sudo echo "extension=pdo_pgsql.so" >> path to php.ini. Find the path using php -i | grep php.ini
That should install pdo driver for postgres
Note
It is possible that sudo make install doesn't work. It might be due to an OSX feature known as csrutil. Reboot your machine and hold down cmd + R. From the recovery inteface run csrutil disable from terminal.
Reboot again and perform the make install. Repeat same process as in the paragraph above to enable csrutil by running csrutil enable at the recovery interface's terminal.
here is the output im getting.
showing output after running this command : pecl install apc
downloading APC-3.1.13.tgz ...
Starting to download APC-3.1.13.tgz (171,591 bytes)
.....................................done: 171,591 bytes
could not extract the package.xml file from "/build/buildd/php5-5.5.9+dfsg/pear- build-download/APC-3.1.13.tgz"
Download of "pecl/apc" succeeded, but it is not a valid package archive
Error: cannot download "pecl/APC"
Download failed
install failed.
I have to install apc via cmd.
problem im facing is installation failure.
Try using the default system apc install:
sudo apt-get install php-apc
Here is how I install PHP APC:
Download latest stable Version
PHP APC-3.1.9 (stable) can be found on PECL page. Download and save (to desktop).
Begin installation
Untar APC, move into extracted directory
tar xvzf APC-3.1.9.tgz
cd APC-3.1.9/
Now, we want to phpize current directory. Because I use LAMPP PHP installation, its phpize is located in /opt/lampp/bin. Then, new .configure file will be created (your php-config may differ).
/opt/lampp/bin/phpize
./configure --with-php-config=/opt/lampp/bin/php-config
Then,
make
sudo make install
Configure php.ini file
Next, we want to configure APC for use. Edit your php.ini file. (mine was located in /opt/lampp/etc/php.ini).
vim /opt/lampp/etc/php.ini
Add these lines (preferably under Dynamic Extension section, but you can place it anywhere):
extension=apc.so
apc.enabled=1
apc.shm_size=40M
apc.ttl=7200
apc.user_ttl=7200
apc.enable_cli=1
apc.max_file_size=5M
also edit extension_dir on php.ini file
extension_dir = "/opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/"
your extension_dir refers to make install result.
Now, look at phpinfo() page to verify your APC installation.
References:
Install guide
I'm having issues setting up my PHP development environment on OS X after installing OS X 10.9 Mavericks.
Here is the command I am using to install.
sudo pecl install xdebug
downloading xdebug-2.2.3.tgz ...
Starting to download xdebug-2.2.3.tgz (250,543 bytes)
.....................................................done: 250,543 bytes
66 source files, building
running: phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
ERROR: `phpize' failed
Anyone have a solution or a workaround?
The fast copy-paste way
sudo sh -c 'echo zend_extension=$(find /usr/lib/php/extensions -name "xdebug.so") >> $(php -qr "echo php_ini_loaded_file();") && apachectl restart'
This command do the following :
Finds the native Xdebug extension that comes with Xcode
Asks php which config file is loaded
Adds the Xdebug extension path in the config file
Restarts apache.
Compatible with Sierra, El Capitan & Yosemite with the bundeled apache, but untested with MAMP & XAMPP.
Before launching the command, make sure Xcode command line tools are installed : xcode-select --install
Don't know about using pecl. Getting Xdebug after an OS X install is pretty straightforward without pecl. You've got two easy options:
Use the version already available at:
/usr/lib/php/extensions/no-debug-non-zts-2010052/xdebug.so
Build your own:
Make sure you have the Xcode CLI tools: xcode-select --install will prompt you to install the CLI tools. With the CLI tools installed, there should be stuff inside /usr/include/php.
Go to http://xdebug.org/download.php and download the source tarball for the version of Xdebug you want. For example: http://xdebug.org/files/xdebug-2.2.3.tgz.
Extract the tarball and cd into the directory it created. Inside that directory you'll see a README. From here it's:
$ phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
$ ./configure --enable-xdebug
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
[... output ...]
$ make
[... output ...]
Your built xdebug.so is now at modules/xdebug.so. The phpize is critical to do with XCode CLI tools installed, because phpize sets up the build parameters for your version of PHP.
With your xdebug.so in hand from (1) or (2) above, you can add this block to the php.ini being used by your php or php-fpm:
[Xdebug]
zend_extension=<full_path_to_xdebug.so>
xdebug.remote_enable=1
xdebug.remote_host=<host running PHP (e.g. localhost)>
xdebug.remote_port=<port Xdebug tries to connect to on the host running PHP (default 9000)>
There are two issues here. The first is that you need to install Xcode command line tools with the command:
xcode-select --install
This will mean that the files previously not found in /usr/include/php/ will be available.
The next step is to install autoconf in the same way as Ares shows in his answer.
I would cd into your download folder first
cd ~/Downloads/
curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz
tar xzf autoconf-latest.tar.gz
cd autoconf-*
./configure --prefix=/usr/local
make
sudo make install
now you can run the pecl install command
sudo pecl install xdebug
If you are using Mac Yosemite 10.10 and none of the above answers solved the problem. Do the following:
Open a terminal
Execute find /usr/lib/php/extensions -name "xdebug.so" to know the path to the debug library.
Execute sudo nano /etc/php.ini to open and edit the php.ini file
In php.ini add the following lines at the end
[XDebug]
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
(When finished, type control+o to save and control+x to close the file)
(Don't forget to replace the value in zend_extension for whatever you got from the first terminal command)
Execute sudo apachectl restart to load the new configuration
Sit back and relax
For anyone who is facing this issue I had to build autoconf from source. I followed this answer from another StackOverflow question.
https://stackoverflow.com/a/12333230/2272004
For the issue phpize error,try this will solve your problem:
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include /usr/include
I had to brew install xdebug and choose for my version of PHP and it worked!
For example,
brew install homebrew/php/php56-xdebug
For a PHP version 5.6 variant.