Mongo PHP Driver 1.2.10 with MAMP - php

I'm trying to get the latest Mongo Driver to work with MAMP 1.9.6 on OS X 10.5.8.
I built it successfully from source since it seems that there are no pre-compiled releases, included it into the right directory and restarted the apache.
But PHP doesn't recognize the extension. I used the 1.0.11 driver previously which worked fine, but I need the new version, because Doctrines ODM requires it.
When I replace the 1.2.10 mongo.so with the 1.0.11 and restart apache mongo is available. I don't get what could be wrong.
Anyone had this behaviour or any guesses to get this to work?
Update: The PHP error log shows the following:
[01-Jun-2012 22:02:37] PHP Warning: PHP Startup: mongo: Unable to initialize module
Module compiled with module API=20060613
PHP compiled with module API=20090626
These options need to match
in Unknown on line 0
I'm not quite sure what it means?
2. Update:
I was finally able to sync the API version of phpize.
But now I'm not able to build the driver anymore.
I do the following:
phpize
./configure
make
sudo make install
But at the make command I'm getting tons of syntax errors. Seems that it can't find several header files.
The very first one is the zend_config.h and really I just have those other two files:
zend_config.nw.h
zend_config.w32.h
I downloaded the MAMP components to get this files. Why am I missing this one? And there are a lot of others.
I'm using PHP 5.3.5 Is there a way to get those header files from a different source?

I followed the instructions at Develop MongoDB web apps with MAMP under Mac OS X to successfully build mongo.so for MAMP with php 5.3 on OS X 10.7.3.

I'm adding this for historical purposes -- I guarantee that if you're having the same set of problems, you'll want to do this.
Personally, I had a really difficult time getting MAMP's php version to play nicely with the extension builds that I was trying to make.
I discovered that the problem was that MAMP really hadn't been set up to add extensions in general, and during the compilation of the mongo php drivers, it wasn't installing it in the right place -- so I followed the following tutorial on preparing MAMP for additional pecl and pear extensions.
After following those steps to prepare MAMP for adding extensions, you can easily install any extension.
At the part where it starts talking about adding an extension, use sudo pecl install mongo and restart apache from your MAMP interface.

I ran into the same problem when upgrading from PHP 5.3 to 5.4 and was able to solve it by following these steps:
Make sure to upgrade php5-cli as well as just php5 and php5-common
Uninstall the mongo drive
sudo pecl uninstall mongo
Re-install the mongo driver
sudo pecl install mongo

Related

How to run PHP with Firebird InterBase in VestaCP (CentOS)

I'm running VPS with VestaCP (CentOS) and I had previously installed InterBase for PHP 7.0.30, but after an yum-update and v-update-sys-vesta-all interbase was no longer running.
Here is what I've got so far:
Okay soo with new update the new PHP 7.1.17 version was installed. Allright, but the interbase module is not running with it.
And first thing I did was yum --enablerepo=remi install php71-php-interbase to install interbase for this new PHP version.
Tried to restart but still getting missing InterBase error if I try to use ibase_connect() function - therefor InterBase is still not properly installed.
I tried to follow PHP InterBase documentation on this, but I realized I have to compile it and add extra parameter on run, but the problem is that VestaCP uses different directories and libraries so I don't want to mess up my VPS.
Has anybody dealt with this? Any "howto's" to follow?
This answer is what #Mark Rotteveel already pointed out in the comments, but only with additional steps.
I had to compile PHP 7.1.17 from source with --with-interbase[=DIR] in configuration and then include it in php.ini
[UPDATE]
I found even faster way to do this automatically (if only I had known this earlier I would have saved few hours of research).
Answer
Just run yum -y install php php-interbase and you will be all set.

Install PHP 7.0 Internationalization extension (Intl) on XAMPP on Mac

I followed the instructions outlined here:
Install PHP Internationalization extension (Intl) on XAMPP on Mac
Ran sudo pecl install intl
selected the correct files from the Cellar
then this error happened:
/private/tmp/pear/temp/intl/intl_error.h:24:10: fatal error:
'ext/standard/php_smart_str.h' file not found
include
^ 1 error generated. make: *** [php_intl.lo] Error 1 ERROR: `make' failed
No matter, did some research and found out that PHP 7.0.8 deprecated php.smart_str.h to php.smart_string.h
So given my scant knowledge of C++ I copied smart_string.h to smart_str.h and renamed all the headers from STRING to string.....
re-ran pecl -no luck....more errors......without knowing where the .c files are and remaking php (not really interested in going that far) since anyway I'm using XAMPP so that ended that option.
I have php 5.5 on my mac, deep in the usr/local/bin folder
so next step was to get pecl to use those files and generate an intl.so file....
Did that....I have the intl.so file so put it in the 'extensions' folder in XAMPP (for reference: /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012)
Ran php and came up with this error:
Warning: PHP Startup: Unable to load dynamic library
'/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so'
- dlopen(/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so,
9): Symbol not found: _zval_used_for_init Referenced from:
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so
Expected in: flat namespace in
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so
in Unknown on line 0
I imagine it has to do with different versions?
In any case I can't get pecl to install intl without a make error in PHP 7.0.8 on XAMPP. There is no documentation on this and you'd think that if you deprecate a header.h file you'd update all extensions?
Install intl.so in PHP 7 seems impossible?
After a lot of research I was finally able to resolve this. Detailed steps here:
before you begin, check which php path is set. it should be /Applications/XAMPP/xamppfiles/bin/php. If not you can change it by PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}". more detail here
Overall idea is to build the intl-extension from PHP source code on your own. Before you begin make sure you have installed Xcode. Also, install the latest version of autoconf. this might help:
brew install autoconf
Next download the version of PHP you use in XAMPP from php.net. I am using 7.1.18. This version worked for me: php-7.1.31, I’m guessing if you follow the steps it might work for 7.0 or 7.2 as well. Do let me know if it does or doesnt, I’ll update this post. Do not use PHP 7.3 for Magento 2.3.0, it is not supported.
Extract the tar.gz file using (I extracted it inside ~/Downloads/ folder )
tar -xzvf php-7.1.31.tar.gz
cd into the extracted folder
cd php-7.1.31
change to subfolder ext/intl
cd ext/intl/
Run these commands to build the extension
/Applications/XAMPP/bin/phpize
./configure --enable-intl --with-php-config=/Applications/XAMPP/bin/php-config --with-icu-dir=/Applications/XAMPP/xamppfiles/
make
sudo make install
you can now delete all files you downloaded and also the extracted folders.
Open /Applications/XAMPP/xamppfiles/etc/php.ini , and add extension=intl.so
Restart your Apache using XAMPP GUI and it should work.
So far, it seems that extension intl.so for php is bundled with php
and should be compiled with php (intl --enabled). XAMPP does not support this (as of Oct 2016), MAMP does. I do not know about other distros. However, if you're willing to recompile PHP 7, it's worth it just to do that and enable it during compiling.
So....I ran with MAMP. Then I decided that I would simply install apache 2.4 and php 7 and Mysql without the stack and the junk that comes with MAMP or XAMPP and everything works like a charm... so if you need to use CakePHP or intl support etc... just drop XAMPP/MAMP and go with a standard install. I used homebrew (MacOS) and everything is working fine.
Update: As regards Windows, XAMPP does not default it, but you can add the module (dll) in php.ini and works like a charm
The error means that XAMPP doesn't have PHP compiled with intl. You may try:
pecl install intl
but probably it won't work as well.
See: PHP Bug #72879 Pecl install intl make error with PHP 7.0.8.
As for the workaround, try installing memcached extension instead of memcache, e.g.
pecl install memcached
Note: It also requires libmemcached package/library to be installed beforehand. For macOS, install via: brew install libmemcached.
If you wanna try without homebrew, with native apache and php, look at my aswer here: https://stackoverflow.com/a/55131868/3692846

Php pdo mysql not found

I have already done much digging on installing/enabling PDO mysql extension on stackoverflow and many other sites, so please do not consider this as a duplicate question
I am on centos 6.5 and has php 5.5.26 which was compiled with make, make install (I know this is an older version so please do not close question or suggest updating to new php version. Also cannot install php using yum as this is what has been installed already me and should not be installed/changed).
So when I did compile php and added it to apache, it does not show mysql PDO driver. I tried putting extension=pdo_mysql.so to ini file with no success (yes I did restart the server as well, after making changes).
It shows pdo enabled, but only for drivers pgsql and sqlite.
Also, tried installing php-mysql package using yum. But the issue with yum installation is it installs 5.3.3 version of driver which complains about compatibility issues as my php version is 5.5.26.
So I am not sure what I need to do install pdo mysql extension
#Peter Darmis was right from his comments.
PHP 5.3.3 was not completely uninstalled, don't know why.
There was already a PHP installed manually be compilation and, as I wasn't aware about this, I was using yum for installation of modules and at that time PHP 5.3.3 got installed which I don't know why it dot un-install properly.
So I ended up with 2 PHP versions, so uninstalled PHP 5.3.3 completely using yum and then resolved this issue compiling PHP with pdo options

Mailparse and PHP 5.6.2?

Is there a version of Mailparse that works with PHP 5.6.2? I installed it this morning using pecl install mailparse and it placed mailparse.so in what seems to be the wrong location and when I view it in Finder it shows up as a document.
I decided for the heck of it to copy it to the appropriate folder and when I execute the code the uses it I get these messages:
Warning: PHP Startup: mailparse: Unable to initialize module
Module compiled with module API=20121212
PHP compiled with module API=20131226
These options need to match
in Unknown on line 0
FYI, I'm not a PHP expert by any stretch.
For php 5.6 and debian first install php5-dev module:
apt-get install php5-dev
and next use latest build for php5, which is currently:
pecl install mailparse-2.1.6
If mailparse is already installed you can remove it before any action:
pecl uninstall mailparse-2.1.6
Officially, no, there's not.
http://php.net/manual/en/mailparse.installation.php
Windows users will enable php_mailparse.dll inside of php.ini in order
to use these functions. A DLL for this PECL extension is currently
unavailable. See also the building on Windows section.
It seems to be just a matter of compiling, so anyone should be able to compile it and share the DLL, but as far as I know no one has done this.
mailparse hasn't had a release for some years - though the git repo is showing recent work (April 2015). I recently used it for a project, however the version I used had some issues in decoding the display-name & email from a list of not perfectly formatted string of multiple names.
I've since installed mmucklo/email-parse and I'm using that as a native PHP solution on PHP 5.6.

Does the mongodb php driver require php5-dev?

I'm trying to install mongodb in a PHP environment. MongoDB itself is installed fine, I've run pecl install mongo, and added extension=mongo.so to php.ini; but my Laravel application complains that it can't find the class MongoClient. Checking phpinfo() reveals no mention of Mongo, suggesting that it isn't aware of the driver.
I noticed that all the instructions for installing mongo on Ubuntu mention apt-get install php5-dev. Is that a requirement for the mongodb php driver? At the moment the server is built with Chef and installs php with apache2::mod_php5. If php5-dev is required, can it be installed as an apache module?
Yeah you should as stated by docs here http://docs.mongodb.org/ecosystem/drivers/php/
Also if its unable to find mongo drivers ,Try debugging , check logs if it says something like mongo.so file is missing.
Don't forget to restart php and apache after saving php.ini

Categories