Install Xdebug extension only for PHP7.1 - php

I have PHP 7.1 on Ubuntu 16.04 installed. When I'm trying to install Xdebug by using apt-get install php-xdebug, I'm getting xdebug.ini in directories 5.6, 7.0 and 7.1.
I don't need /php/5.6/mods-available/xdebug.ini and /php/7.0/mods-available/xdebug.ini extensions, because I'm using only PHP 7.1 version.
Any ideas?
Thanks.

It's because php-xdebug is ambiguous and will download the default package which will contain multiple versions for php compatibility, try going to xdebug site and download the code, then make/build it https://xdebug.org/

try:
apt install php7.1-xdebug
If I good understood, you don't want to have many xdebug ini files. Ubuntu supports many php versions, which you can switch if you need. If you want to have single xdebug configuration file, I recommend to create catalog mods-available in /etc/php, move xdebug.ini there and make symbolic link from all required paths (for apache2, cli for every php version you need) - for example, for PHP 7.1 with Apache
ln -s /etc/php/mods-available/xdebug.ini /etc/php/7.1/apache2/conf.d/20-xdebug.ini

I used these commands to get xdebug installed and running on 7.2
git clone git://github.com/xdebug/xdebug.git && cd xdebug
apt-get install -y php7.2-dev && ./rebuild.sh
service php7.2-fpm restart

Xdebug has an awesome wizard(form) where you can just paste the content of your php.ini or results of php -i command and get step by step instructions on how to go about setting it up.
In my experience, it's the most reliable and error-free method and I have used in vagrant instances with both mod-php and php-fpm 7.1 & 7.2 versions without any issues.
https://xdebug.org/wizard.php

Related

Install MongoDB PHP Extension for PHP 8.1 (Debian)

sorry if there is a duplicate question for this but I'm trying to set this up for hours now and it just doesn't work.
I have a Debian 11 server with "KeyHelp" installed on it (little brother of plesk). It comes with PHP 7.4 but provides a simple Dashboard where you can install other PHP versions. I installed PHP 8.1 and tried to install the mongodb extension via PECL.
After "pecl install mongodb" I added "extension=mongodb.so" and after that didn't show up the extension on the phpinfo page, I double checked if the extension is really in the extension folder of php, where it was.
Turns out that I installed the extension for PHP 7.4 and not for PHP 8.1. Finally I tried to force PECL to install it for PHP 8.1 but it says "phpize8.1 command not found". I found no way to install phpize8.1, can somebody help me out with that?
Thanks in advance!
I am using Ubuntu 20.04
I have PHP 8.1 version. You have to install modules of PHP
sudo apt install php8.1-mongodb
List the modules
php -m
It's not exactly Debian. I hope it helps you.
If you run command:
sudo apt install php-dev
System will install automatically the correct version of php{x}-dev for your distribution, and all it's dependencies, included PECL.
another way is try to run:
/usr/bin/phpize
If this command works, you need to add phpize to your PATH:
PATH=$PATH\:/usr/bin; export PATH
In this way phpize will work in future.

Nginx SOAP extension is installed for PHP 7.0 but not 7.4

I have an Ubuntu 16.04.6 machine and need the SOAP extension enabled for PHP 7.4, but right now it's only installed for 7.0 The extension itself is present in path /usr/lib/php/20151012/soap.so
I've used apt-get remove php-soap and the apt-get install php-soap but it does not get installed anywhere except the 7.0 folder. I have noticed in the 7.0 folder there are certain files and symlinks, which I have duplicated into the 7.4 folder structure. /etc/php/7.4/mods-available now contains soap.ini and a symlink to it named 20-soap.ini was placed in folder /etc/php/7.4/fpm/conf.d This is in keeping with all the other extensions, which were all installed almost exactly a year ago when I upgraded PHP.
In the php.ini file I have uncommented extension=soap.so and I have tried changing that line to extension=/usr/lib/php/20151012/soap.so
service php7.4-fpm restart
service nginx restart
All this to no avail. Can someone slap me upside the head and tell me what I'm missing? Should I try deleting previous PHP versions, then reinstalling the soap extension? I've seen threads mentioning specific packages for 7.4 such as php7.4-soap but this is not found in my repositories.
Any help is appreciated!
Try this command apt install php7.4-soap
sudo add-apt-repository ppa:jczaplicki/xenial-php74-temp
sudo apt-get update
sudo apt install php7.4-soap
This is adding an external PPA repository to your system. If you do not trust the maintainer you should not do this, since it possibly exposes your system. Also note that this might work for installing php, but there will not be a guarantee that you recvive updates through it (The word "temp" in the repository name indicates that this is only temporary). I would rather recommend compiling it yourself if you really need to have it installed on 16.04.
Also this will install you php version 7.4.13 , you may have to remove the already installed php 7.4 , and reinstall after you add this ppa

Install phpredis MAC OSX

Can anyone help me install php-redis in MAC OSX .
brew install php-redis
not working.
pecl install php-redis
also not working getting -
invalid package name/package file "php-redis".
Homebrew Error:
homebrew_error
git clone https://www.github.com/phpredis/phpredis.git
cd phpredis
phpize && ./configure && make && sudo make install
Add extension=redis.so in your php.ini
brew services restart php#7.2
make test
You can check working or not
php -r "if (new Redis() == true){ echo \"\r\n OK \r\n\"; }"
As of 2019, with homebrew php7.2 and up, pecl is now installed by default alongside the php binaries.
To see this for yourself type which pecl.
Steps to install
Check your version of redis, then find a suitable version of the extension here.
If unfamiliar with pecl, type pecl to see the options.
Issue pecl install redis-5.0.2. (or your version). Enter no to each question asked if you're not sure.
If that succeeds check the new file it created at: /usr/local/lib/php/pecl/20180731/redis.so
The install will have added extension="redis.so" to top of your php ini.
Check that by opening the file /usr/local/etc/php/7.3/php.ini.
(assuming you're on 7.3 there)
brew services restart php.
php -i | grep Redis
Redis Support => enabled
Redis Version => 5.0.2
This is what I just did in September 2019 and it works for me.
If what mwal wrote above doesn't work (please try his/her answer first),
first, try to uninstall first (if you have it but broken):
sudo pecl uninstall redis
and after that run:
sudo pecl install redis
After that, ini the php.ini, use full path for the extension.
Mine was /usr/local/Cellar/php#7.3/7.3.21/pecl/20180731/redis.so (assuming you are using php#7.3)
so at the top of my php.ini file is like this:
extension="/usr/local/Cellar/php#7.3/7.3.21/pecl/20180731/redis.so"
Here are steps to use pickle, for PHP >= 7.3 (tested with 8.1):
brew install pickle
pickle install redis
Find your php.ini location via php -i|grep php.ini
Edit the php.ini, insert extension=redis. Preferable at Dynamic Extensions section.
No restart of Apache httpd service is required. You may test your PHP code with Redis
Bonus
If you use VS Code, to enable intellisense / auto complete, at Preference -> paste intelephense.stubs at Search setting box -> Add Item -> select redis.
If you got the following error,
Please make sure the PHP Redis extension is installed and enabled
despite doing everything in the verified answer above, try valet restart . It worked for me
I have tried all these solutions but didn't work for me for a while so I tried this link https://developer.redis.com/develop/php/ from the original docs and it works as charm
If someone gets an error during sudo pecl install redis
Warning: mkdir(): File exists in System.php on line 294
PHP Warning: mkdir(): File exists in /opt/homebrew/Cellar/-----/pear/System.php on line 294
that means you need to create the broken directory manually.
Try to create the directory...
pecl config-get ext_dir | pbcopy
mkdir -p {paste clipboard value}
# in my case, it was
mkdir -p /opt/homebrew/lib/php/pecl/20200930
Now try to install any pecl extensions.
sudo pecl install redis
After installing any extension, restart php
brew services restart php
Happy coding :)

I do not get APCu installed with PHP 7.2 on my Mac

I changed my default apache server setup on my mac to be able of easily switching between php versions following this guide.
Now, when I return to my project which is based on the CMS TYPO3, I get the error, that "The PHP extension "apcu" must be installed and loaded in order to use the APCu backend.".
So I was following the tutorial (by the same author) to install and enable apcu.
I can sum up the installation process:
$ sphp 5.6
$ brew install autoconf
$ pecl channel-update pecl.php.net
$ pecl install apcu-4.0.11
This actually worked perfectly for php 5.6! But I wanted php 7.2 for my project. The tutorial instructs to do this:
$ sphp 7.2
$ pecl uninstall -r apcu
$ pecl install apcu
No errors here. But the CMS still claims no apcu! Searching for "apc" in phpinfo also returns in no results! Pecl added the extension="apcu.so" line in the loaded php 7.2 ini, so I don't understand what's wrong. Of course I restarted apache every time. Also no errors or warnings here.
Also after googling I have no idea what to do :/
You may try using an absolute path of the apcu.so in php.ini,
Like
extension="/usr/local/Cellar/php/7.3.2/pecl/20180731/apcu.so"
The path depends. Don't know why but this works for me anyway.
You may also need to check the following ini config entry for apcu:
apc.enabled=on
apc.enable_cli=on

Where can I download Xdebug for PHP and Mac OS X?

I went to the xdebug site, but I can't find a mac download.
http://www.xdebug.org/download.php
Did I miss something? NetBeans tells me to get xdebug for setting up an PHP development environment on the mac.
You can just use the PECL download option, but you'll need to add a sudo
sudo pecl install xdebug
Then set the path to xdebug in your php.ini file. If everything is still at the default I'd imagine you'd need:
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
However, you can check your extensions directory via:
pecl config-get ext_dir
(You will need to restart Apache after this install, either via the command line or by turning web sharing off and on again in System Preferences.)
HTH
Use Homebrew.
brew install php55-xdebug
Or php56-xdebug or php70-xdebug depending on your PHP version.
You will need to compile it from source. Or alternatively, maybe this tutorial on getting xdebug working on mac os x with macports will help.
If you have pecl, this would be a good way.
# pecl install xdebug
If you don't have pecl, you may want to ckeck it out.
If your macOS is 10.14 Mojava, xdebug 2.5.5 was bundled in /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
If you want to compile xdebug and you are using laravel, check this https://github.com/laravel/framework/issues/27052 for Compatability Notice
PHP 7.2.x + xdebug 2.6.x all good.
PHP 7.3.0 + xdebug 2.7.0beta1 known issues.
PHP 7.3.1 + xdebug master branch all good. // I can verify this is NOT the case,
//no xdebug commits so far (2019-01-24) work for php 7.3.1, as least not working on my mac
If you want to use pecl to install xdebug, you will need to use brew to install php first because php 7.1.9 bundled with Mojava does not have pecl.
The simplest way is to get the precompiled binaries maintained by Komodo from here (choose the most recent 'PHP Remote Debugging Client' package), then unzip it, find the folder that corresponds to your version of PHP e.g. 5.3 and copy the xdebug.so file from there into your php extensions folder.
Then adjust php.ini as outlined in the other posts.
5 years later, OSX is now bundled with Xdebug. For those who came here with Google : just copy-paste the following in your terminal to activate the extension :
Mavericks 10.9
sudo sh -c 'echo "zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so" >> /etc/php.ini && apachectl restart'
Mountain Lion 10.8
sudo sh -c 'echo "zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so" >> /etc/php.ini && apachectl restart'

Categories