MongoClient not found in PHP - php

I have downloaded php_mongo-1.3.2RC1.zip from https://github.com/mongodb/mongo-php-driver/downloads
Then I have extracted all of them in my C:\xampp\php\ext directory. To use mongodb though php file located in 'C:\xampp\htdocs\index.php' directory, I have added extension=php_mongo-1.3.2RC1-5.2-vc9.dll this line to C:\xampp\php\php.ini.
Yet I have got this error Fatal error: Class 'MongoClient' not found. What can I do to make it work?
I am using Xampp on windows 8 64 bit running on php 5.2.
I have tried writing php on cmd and it returns this following lines:
Warning: PHP Startup: mongo: Unable to initialize module
Module compiled with module API=20060613
PHP compiled with module API=20100525
These options need to match
in Unknown on line 0
I have tried phpinfo() as #j0k has asked, and it returned:
Configuration File (php.ini) Path C:\Windows
Loaded Configuration File C:\xampp\php\php.ini

Try this:
pear install -f pecl/mongo

I think you use php 5.4 (info from my web server):
$ php -v; phpize -v
PHP 5.4.11 (cli) (built: Feb 10 2013 03:38:26)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
API module versions are identical.
…
Module compiled with module API=20060613
…
It is php 5.2 (from source code):
$ grep '#define ZEND_MODULE_API_NO' php-src-php-5.2.17/Zend/zend_modules.h| sed 's/#define ZEND_MODULE_API_NO//'
20060613
Check you version php (php -v; phpize -v) and setup php-mongo-driver. You can see versions in phpinfo(); (recommended; PHP API, PHP Extension, Zend Extension, Thread Safety)

Try to restart your Apache. Apache will not try to reload the configuration upon edit. For xampp you can do this in the cornor pressing shutdown or restart, if I Remember correctly. Alternative you can restart your pc

From this page:
Note: Additional DLL dependencies for Windows Users:
In order for this extension to work, there are DLL files that must be available to the Windows system PATH

Related

PHP 7.2 memcached extension on Mac OS

I am trying to setup php memcached extension on mac OS High Sierra. I am running php 7.2
Output of php -v:
PHP 7.2.6 (cli) (built: May 25 2018 06:18:43) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.6, Copyright (c) 1999-2018, by Zend Technologies
I installed memcached via pecl without any error:
pecl install memcached
It is enabled in php.ini file:
extension="memcached.so"
When I run <?php echo phpinfo();?> on my Apache server. I can see session configured:
session.save_handler memcached memcached
My symfony application gives me still this error:
(1/1) ClassNotFoundException
Attempted to load class "Memcached" from the global namespace.
Did you forget a "use" statement?
EDIT:
My apache is running a different version of php (PHP Version 7.1.16) I don't know why but I think this cannot be a problem.
In info file I can see in the CORE section that php extension dir is "/usr/local/lib/php/pecl/20170718". When I open that directory there is memcached.so file. The path is correct.
EDIT 2:
In my apache logs I see warning:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/pecl/20170718/memcached.so' - dlopen(/usr/local/lib/php/pecl/20170718/memcached.so, 9): Symbol not found: _zend_empty_string\n Referenced from: /usr/local/lib/php/pecl/20170718/memcached.so\n Expected in: flat namespace\n in /usr/local/lib/php/pecl/20170718/memcached.so in Unknown on line 0
So. Apache and SLI php version use diferent php.ini files.
For examle on my Debian 9 it use /etc/php/7.2/apache2/php.ini and /etc/php/7.2/cli/php.ini
I believe your problem is that you are using a different version of PHP.
Just try comands below:
$sudo a2dismod php7.1
$sudo a2enmod php7.2
$sudo service apache2 restart
If you still get same Error try create info.php in your www root dir thich conteint next code:
<?php
phpinfo();
And check Memcache are loaded.

MAMP ext mongo.so not loading. How to fix it?

I know there's multiple post about this, but I tried almost everything i found out ..
My problem is that I'm trying to add mongo.so to my MAMP server. It compiles perfectly with the phpize of MAMP and php-config of MAMP. But when I'm trying to put it in the php.ini, it doesn't load it ..
php --version :
PHP 5.5.14 (cli) (built: Jul 25 2014 17:02:08)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
phpize -v :
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
php --ini :
Configuration File (php.ini) Path: /Applications/MAMP/bin/php/php5.5.14/conf
Loaded Configuration File: /Applications/MAMP/bin/php/php5.5.14/conf/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
I tried changing that php.ini, restart and nothing ..
I tried changing the php.ini in /Applications/MAMP/conf/php5.5.14/, restart and nothing ..
What else is needed to adjust to fix it?
EDIT:
I just found out that the PHP API on my phpinfo() page is set to 20121113. What I don't understand is why that doesn't take the same version on my phpize related to the php server ...
Finally, I fixed it myself. For everybody passing by, please note that this was my PHP sources that was not in the good version. So the extension was not configuring with the right version.

FFMPEG on Fedora but PHP Compilation confliction

I have running Xampp with PHP5.5 on Fedora from Apache Friend, with default settings what the installer package do on Linux.
When I install FFMPEG successfully and try to load from php.ini it always says:
*
11-Oct-2013 14:05:51 Europe/Berlin] PHP Warning: PHP Startup: ffmpeg: Unable to initialize module
Module compiled with module API=20060613
PHP compiled with module API=20121212
These options need to match
in Unknown on line 0
*
The only thing which is confusing me is that when I did phpize even that I already installed xampp server which means I have PHP running. FFMPEG phpize did not work and I had to install php-devel. Does that mean that FFMPEG is configured with PHP, other than the installed with XAMPP? I am not sure what is happening. Whatever I do I always receive this error message in php_error_log file.
It is amazing :) that I just run below command to see what version of PHP is, I have and below are the results which are shocking one because I am in a feeling that I have PHP 5.5 installed and running from XAMMP.
[root#localhost ~]# php -v
PHP 5.2.6 (cli) (built: May 8 2008 08:53:44)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
How can I get this covered that if I simple install XAMPP server on linux and want to install and configure FFMPEG along with?
My guess would be that the versions of php and the module you installed do not match. So run make sure both packages are installed from the same source and are both current.
EDIT: According to the XAMPP site, Fedora is not supported, they specify Ubuntu, SuSE, RedHat, Mandrake and Debian. So I would make sure you do not use the php package provided by Fedora. Or (if you have the liberty), choose a different OS.

PHP Apache ImageMagick extension won't load

I am runnning 64-bit Windows 7 with Apache 2.2, PHP 5.4.4 VC9. I have downloaded and installed ImageMagick 6.6.4 and successfully tested it from the command prompt. I have restarted my computer. I have tried many different extension files and keep getting the following error in my Apache logs.
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\PHP\\ext\\php_imagick_ts.dll' - The specified procedure could not be found.\r\n in Unknown on line 0
I have my extension_dir set to C:\PHP\ext. And I of course have added the line extension=php_imagick_ts.dll modified according to which file I am trying.
I have Imagick working on Win7 x64 with PHP 5.4 (only tested commandline, but Apache should work) using the beta libraries as compiled and hosted here: http://www.peewit.fr/imagick/
I installed ImageMagick via the ImageMagick-6.8.0-7-Q16-windows-dll.exe file on the ImageMagick downloads page.
C:\>php -v
PHP 5.4.0 (cli) (built: Feb 29 2012 19:24:02)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
C:\>php -m
[PHP Modules]
...
imagick
...
I haven't actually tested using this extension yet, but I'm fairly confident that this will work, given that all of the other .dlls I tried resulted in php.exe crashing when I tried simply running php -v!
The only thing that ended up working for me was to load php 5.3. Began working immediately.

Error in httpd.conf. Can't locate API module structure `php5_module'

I've recently installed phc, the php compiler. I started out installing LAMP from source with --enable-so for Apache and --enable-embed for PHP5 (among other options these are most relevant to the installation and later configuration).
When I finished installing I realized phc does not yet support PHP5.3 so I uninstalled it and installed PHP5.2. phc works fine now, as does the PHP client application for the commandline. Apache seems to be running fine, too, when I comment out line 193 (see below). It just doesn't parse PHP.
httpd: Syntax error on line 193 of /etc/apache2/conf/httpd.conf: Can't locate API module structure `php5_module' in file /usr/local/lib/libphp5.so: /usr/local/lib/libphp5.so: undefined symbol: php5_module
When I check my version of PHP from the terminal I get the expected output (5.2):
[root#localhost conf]# php -v
PHP 5.2.14 (cli) (built: Sep 7 2010 22:50:25)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
I made sure to move the libphp5.so file from the folder where I built php5.2 (/usr/local/src/php-5.2.14) to /usr/local/lib. I also moved php.ini to /usr/local/lib.
Is there something I'm missing here?
OK!
Apparently when you configure PHP it's important to include the line specifying wehre to find apxs for the proper installation:
--with-apxs2=/etc/apache2/bin/apxs
I did this and the problem vanished :)

Categories