Why mongodb not shown on my phpinfo? - php

I have installed mongodb but somehow it is not showing on my phpinfo.
here are more details from my terminal:
~ $ which php
/Applications/XAMPP/xamppfiles/bin/php
~ $ php -v
PHP 7.1.8 (cli) (built: Aug 17 2017 11:06:55) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
~ $ php --ini
Configuration File (php.ini) Path: /Applications/XAMPP/xamppfiles/etc
Loaded Configuration File: /Applications/XAMPP/xamppfiles/etc/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
~ $ ls /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20160303
mongodb.so opcache.a opcache.so pdo_dblib.a pdo_dblib.so pgsql.a pgsql.so
~ $ mongo --version
MongoDB shell version v3.6.5
I have also included extension=mongodb.so on my php.ini file
Any help is appreciated.

Related

Can't connect PHP to my Visual Studio Code

I got stuck while setting up PHP on my Mac. I downloaded it via brew and I have it on my computer.
PHP 8.0.26 (cli) (built: Nov 23 2022 05:33:21) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.26, Copyright (c) Zend Technologies
with Zend OPcache v8.0.26, Copyright (c), by Zend Technologies
this is what i get when I type php --ini in Terminal:
Configuration File (php.ini) Path: /opt/homebrew/etc/php/8.0
Loaded Configuration File: /opt/homebrew/etc/php/8.0/php.ini
Scan for additional .ini files in: /opt/homebrew/etc/php/8.0/conf.d
Additional .ini files parsed: /opt/homebrew/etc/php/8.0/conf.d/ext-opcache.ini
I tried to add /opt/homebrew/etc/php/8.0 into my settings.json but it didn't work out.
I appreciate any help!
I tried to change path of PHP to MAMP's PHP, but it did not apply. Also I have phpinfo.php file that is located in:
/Library/WebServer/Documents/phpinfo.php

XDebug not listed in the output of phpinfo()

I am trying to enable XDebug so I can use it along with the PHPStorm (I am on Mac) and although I do not have any errors XDebug is not listed in the phpinfo() output. I also tried with XDebug wizard but with the same result. Here are all my configurations:
I modified the /usr/local/etc/php/7.2/php.ini which I get from:
$ php --ini:
Configuration File (php.ini) Path: /usr/local/etc/php/7.2
Loaded Configuration File: /usr/local/etc/php/7.2/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.2/conf.d
Additional .ini files parsed: /usr/local/etc/php/7.2/conf.d/ext-opcache.ini
with the following:
zend_extension ="/usr/local/lib/php/pecl/20170718/xdebug.so"
[xdebug]
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
xdebug.so was installed with pecl without any errors:
$ pecl install xdebug
To confirm that I have the xdebug.so:
The output from php -m is as follows:
[PHP Modules]
ast
bcmath
...
wddx
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Xdebug
Zend OPcache
After all this configurations I run:
$ sudo apachectl restart
But in the output of phpinfo() I do not have it enabled:
I also looked all over the content, but there is nothing connected to xdebug.
Should also note that I restarted my local server before the phpinfo() output:
$ php bin/console server:start --force
My php version (Also you can see that it's showing Xdebug as properly enabled):
❯ php -v
PHP 7.2.27 (cli) (built: Jan 24 2020 03:49:45) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.9.3, Copyright (c) 2002-2020, by Derick Rethans
with Zend OPcache v7.2.27, Copyright (c) 1999-2018, by Zend Technologies
As #LazyOne suggested, I tried rebooting my system and everything started working properly. Looks like something was needing a reboot to start using the new settings/configurations. So if you tried everything and all looks good from configuration point, try rebooting your system.

php -v and phpinfo() loading different php.ini file

I wondered now with XAMPP (MAC) that why the php.ini file is taking wrong in php cli.
phpinfo(); returning correct version 7.1.
php -v returning like below..
sh-3.2# php -v
PHP 7.0.15 (cli) (built: Jan 22 2017 08:50:55) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
sh-3.2# which php
/usr/local/bin/php
sh-3.2# php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/7.0
Loaded Configuration File: /usr/local/etc/php/7.0/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.0/conf.d
Additional .ini files parsed: (none)
I want to make the php-cli version as 7.1 to start my development.
How can I do that ?

XAMPP on Ubuntu: Different PHP versions

UPDATE 16.03.2017:
I checked the log and found the following error:
Xdebug requires Zend Engine API version 320151012. The Zend Engine API version 320160303 which is installed, is newer. Contact Derick Rethans at xdebug.org/docs/faq#api for a later version of Xdebug
I understand that I need to compile xdebug using another PHP header but how do I compile this with PHP7? Also, I am already using the latest xdebug version, which is 2.5.1
I installed xdebug on ElementaryOS together with XAMPP (PHP7) and PHPStorm.
When I enter "php -v" in the terminal, I get the following output
PHP 7.0.15-0ubuntu0.16.04.4 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.15-0ubuntu0.16.04.4, Copyright (c) 1999-2017, by Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
In addition, "php --ini" writes:
Configuration File (php.ini) Path: /etc/php/7.0/cli
Loaded Configuration File: /etc/php/7.0/cli/php.ini
Scan for additional .ini files in: /etc/php/7.0/cli/conf.d
Additional .ini files parsed: /etc/php/7.0/cli/conf.d/10-mysqlnd.ini,
/etc/php/7.0/cli/conf.d/10-opcache.ini,
But when running "phpinfo()" in the browser (hosted by XAMPP) the output does not contain "xdebug" and the php installation seems to be another:
Configuration File (php.ini) Path /opt/lampp/etc
Loaded Configuration File /opt/lampp/etc/php.ini
In both php.ini files, I added the following but still no luck:
;[XDebug]
zend_extension="/usr/lib/php/20151012/xdebug.so"
xdebug.remote_enable=On
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
I checked that xdebug.so exists at this path. It has the following authorizations:
-rw-r--r-- 1 root root 1225696 Mär 14 2016 /usr/lib/php/20151012/xdebug.so
I have no clue what to try next - maybe someone could give me a hint!
Cheers!

PHP7 CLI attempts to load xdebug twice - "Cannot load Xdebug - it was already loaded"

After upgrading Ubuntu from 14.04 to 16.04, PHP CLI started complaining about xdebug:
$ php -v
Cannot load Xdebug - it was already loaded
PHP 7.0.13-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.13-0ubuntu0.16.04.1, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
There is only one .ini file:
$ ls -la /etc/php/7.0/cli/conf.d/ | grep xdebug
lrwxrwxrwx 1 root root 38 Jan 19 11:41 20-xdebug.ini -> /etc/php/7.0/mods-available/xdebug.ini
And it's only referenced once in this output from php -i:
$ php -i | grep -i configuration
Cannot load Xdebug - it was already loaded
Configuration File (php.ini) Path => /etc/php/7.0/cli
Loaded Configuration File => /etc/php/7.0/cli/php.ini
Configuration
And there's only one reference to xdebug in the entire directory (so it's not being included twice):
/etc/php/7.0$ grep -r xdebug *
mods-available/xdebug.ini:zend_extension=xdebug.so
mods-available/xdebug.ini:[xdebug]
mods-available/xdebug.ini:xdebug.remote_enable=1
mods-available/xdebug.ini:xdebug.remote_autostart=1
mods-available/xdebug.ini:xdebug.remote_port=9000
mods-available/xdebug.ini:xdebug.idekey=PHPSTORM
If I do $ phpdismod xdebug I get the following output, suggesting that it still has xdebug loaded:
$ php -v
PHP 7.0.13-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.13-0ubuntu0.16.04.1, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
Having done that it is no longer present in the apache config as shown by phpinfo().
How do I fix this?
Edit: Additional output as requested:
$ php --ini
Cannot load Xdebug - it was already loaded
Configuration File (php.ini) Path: /etc/php/7.0/cli
Loaded Configuration File: /etc/php/7.0/cli/php.ini
Scan for additional .ini files in: /etc/php/7.0/cli/conf.d
Additional .ini files parsed: /etc/php/7.0/cli/conf.d/10-mysqlnd.ini,
/etc/php/7.0/cli/conf.d/10-opcache.ini,
/etc/php/7.0/cli/conf.d/10-pdo.ini,
/etc/php/7.0/cli/conf.d/15-xml.ini,
/etc/php/7.0/cli/conf.d/20-bcmath.ini,
/etc/php/7.0/cli/conf.d/20-calendar.ini,
/etc/php/7.0/cli/conf.d/20-ctype.ini,
/etc/php/7.0/cli/conf.d/20-curl.ini,
/etc/php/7.0/cli/conf.d/20-dom.ini,
/etc/php/7.0/cli/conf.d/20-exif.ini,
/etc/php/7.0/cli/conf.d/20-fileinfo.ini,
/etc/php/7.0/cli/conf.d/20-ftp.ini,
/etc/php/7.0/cli/conf.d/20-gd.ini,
/etc/php/7.0/cli/conf.d/20-gettext.ini,
/etc/php/7.0/cli/conf.d/20-iconv.ini,
/etc/php/7.0/cli/conf.d/20-json.ini,
/etc/php/7.0/cli/conf.d/20-mbstring.ini,
/etc/php/7.0/cli/conf.d/20-mcrypt.ini,
/etc/php/7.0/cli/conf.d/20-mysqli.ini,
/etc/php/7.0/cli/conf.d/20-pdo_mysql.ini,
/etc/php/7.0/cli/conf.d/20-pdo_sqlite.ini,
/etc/php/7.0/cli/conf.d/20-phar.ini,
/etc/php/7.0/cli/conf.d/20-posix.ini,
/etc/php/7.0/cli/conf.d/20-readline.ini,
/etc/php/7.0/cli/conf.d/20-shmop.ini,
/etc/php/7.0/cli/conf.d/20-simplexml.ini,
/etc/php/7.0/cli/conf.d/20-sockets.ini,
/etc/php/7.0/cli/conf.d/20-sqlite3.ini,
/etc/php/7.0/cli/conf.d/20-sysvmsg.ini,
/etc/php/7.0/cli/conf.d/20-sysvsem.ini,
/etc/php/7.0/cli/conf.d/20-sysvshm.ini,
/etc/php/7.0/cli/conf.d/20-tokenizer.ini,
/etc/php/7.0/cli/conf.d/20-wddx.ini,
/etc/php/7.0/cli/conf.d/20-xdebug.ini,
/etc/php/7.0/cli/conf.d/20-xmlreader.ini,
/etc/php/7.0/cli/conf.d/20-xmlwriter.ini,
/etc/php/7.0/cli/conf.d/20-xsl.ini
$ cat /etc/php/7.0/mods-available/xdebug.ini
zend_extension=xdebug.so
[xdebug]
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
As this is still an issue I have found some further detail:
Paths:
$ ls -la /usr/bin/php
lrwxrwxrwx 1 root root 21 Apr 18 2017 /usr/bin/php -> /etc/alternatives/php
$ ls -la /etc/alternatives/php
lrwxrwxrwx 1 root root 15 Feb 12 15:43 /etc/alternatives/php -> /usr/bin/php7.1
php:
$ php -v
Cannot load Xdebug - it was already loaded
PHP 7.1.15-1+ubuntu16.04.1+deb.sury.org+2 (cli) (built: Mar 6 2018 11:10:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.15-1+ubuntu16.04.1+deb.sury.org+2, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
php7.1:
$ php7.1 -v
PHP 7.1.15-1+ubuntu16.04.1+deb.sury.org+2 (cli) (built: Mar 6 2018 11:10:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.15-1+ubuntu16.04.1+deb.sury.org+2, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
The interesting thing there is that the php binary is identical to php7.1 but when called as the specific it doesn't show the already loaded message.
Edit, 20181006:
I still have this issue. The image below is a diff of the output of the two php --ini calls. As you can see, the sets of ini files loaded are the same.
They are also the same symlinked binaries:
ben#ben-work:~$ which php
/usr/bin/php
ben#ben-work:~$ ls -la /usr/bin/php
lrwxrwxrwx 1 root root 21 May 15 16:07 /usr/bin/php -> /etc/alternatives/php
ben#ben-work:~$ ls -la /etc/alternatives/php
lrwxrwxrwx 1 root root 15 May 30 10:13 /etc/alternatives/php -> /usr/bin/php7.1
ben#ben-work:~$ which php7.1
/usr/bin/php7.1
I've fixed this by removing zend_extension=xdebug.so as I already enabled it in my docker container with docker-php-ext-enable xdebug. It might be that it's enabled for you as well.
In Arch Linux the package xdebug generates the following configuration:
/etc/php/conf.d/xdebug.ini
----------
zend_extension=xdebug.so
xdebug.remote_enable=on
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
#xdebug.max_nesting_level=300
This loads twice the same zend_extension=xdebug.so located in /etc/php/php.ini
You need serch the zend_extension declaration in your PHP config dir, for example
grep -Hnir zend_extension /etc/php/7.2/
The command will tell you where you the files:line where is defined the extension, in my case:
/etc/php/7.2/mods-available/xdebug.ini:2:zend_extension=/usr/lib/php/20170718/xdebug.so
/etc/php/7.2/cli/php.ini:1938:; zend_extension = /usr/lib/php/20170718/xdebug.so
/etc/php/7.2/apache2/php.ini:368:zend_extension = /usr/lib/php/20170718/xdebug.so
Here, both cli/php.ini and apache2/php.ini are the same config file but mods-available/xdebug.ini is another file with only xdebug info.
You can comment out or move the lines about xdebug in your php.ini to xdebug.ini and create a joined config under [xdebug] section.
Example:
#xdebug.ini
[xdebug]
zend_extension=/usr/lib/php/20170718/xdebug.so
xdebug.collect_params=4
xdebug.collect_vars=on
xdebug.remote_autostart=on
xdebug.var_display_max_children=128
xdebug.var_display_max_data=4086
xdebug.var_display_max_depth=10
I had the same issue and solved it by removing extra line of code zend_extension="xdebug.so" inside the php.ini file.
The php.ini could be in /usr/local/etc/php/ for mac users but you can run the following command to locate the php.ini file:
$ php -i | grep php.ini
Debian and derivate:
I fixed it locating my php.ini, changing the zend_extension=xdebug.so to the old (so I guess the same would happend commenting the line) zend_extension_ts=zdebug.so.
Then with: php -i | grep xdebug there should be only one conf.d with the zend_extension=xdebug.so. If there were more than one delete the rest of entries.
The cause may indeed be duplicate config files.
In my case 15-xdebug.ini had been added by dnf install php-pecl-xdebug3-3.0.4-1.el8.remi.8.0.x86_64. Listing the INI files shows this:
ls /etc/php*/*xdebug.ini
/etc/php-cli.d/99-xdebug.ini /etc/php.d/15-xdebug.ini /etc/php.d/99-xdebug.ini /etc/php-zts.d/15-xdebug.ini
For users who face the same problem.
In my scenario, it was problem with php cli so every time I tried to get to php in the console, I was getting notice: Cannot load the ionCube PHP Loader - extension already loaded
I guess it will be similar to other extensions.
What I have finally done is:
cd /opt/cpanel/ea-php56/root/etc
grep -r "cube" .
# now I saw two files loading the .so files:
# ./php.d/01-ioncube.ini:zend_extension="/opt/cpanel/ea-php56/root/usr/lib64/php/modules/ioncube_loader_lin_5.6.so"
# ./php.d/pecl.ini:zend_extension="/opt/cpanel/ea-php56/root/usr/lib64/php/modules/ioncube_loader_lin_5.6.so"
mv php.d/pecl.ini .
That was it.
this is just what i faced tried to solve this , this might help someone to figure it out .
obviously, its declared in two places, but no harm in that .
the case for me is that it is declared in the
/etc/php/8.1/cli/conf.d/99-xdebug.ini ( this is the default for some reason )
and here /etc/php/8.1/cli/php.ini
by executing php -i | grep php.ini
you ll find that it mentions the second location only ( my assumption thatit ovverides the firt loading location )
❯ php -i | grep php.ini
Configuration File (php.ini) Path => /etc/php/8.1/cli
Loaded Configuration File => /etc/php/8.1/cli/php.ini
so i commented out the zend_extension line from the second ini file .
After https://stackoverflow.com/users/2192660/javier-domenech
suggestion, that was exact my case. I've discovered two files:
/etc/php/7.4/cli/conf.d/20-xdebug.ini,
/etc/php/7.4/cli/conf.d/99-xdebug.ini.
After deleting the 99-etc, then laravel php server stopped complaining about not finding xdebug (alhough it xdebug worked fine whatsoever).
But most important: This has caused a real exception when trying to run phpunit test suite:
PHPUnit\Framework\Exception: Xdebug: [Step Debug] Could not connect to debugging client
This virtually prevented phpunit from running.
The prior action of deletion, in combination with setting
the attribute: processIsolation="true"
inside of phpunit.xml also solved this weird phpunit issue.

Categories