What is the status of the MongoDB extension for PHP7?

16.8k views Asked by At

PHP7 is gaining a lot of attention lately, promising great performance and a more mature language. Version 7.0.0-alpha is out. We are just starting to rework our core application, which uses MongoDB as data source.

I am wondering if there is any development underway for a PHP7 compatible MongoDB extension? How far is it? Is there any alternative?

7

There are 7 answers

1
Rexxars On

The old Mongo extension for PHP is not going to be supported in PHP7. Instead, there is a new MongoDB extension which is using libmongo under the hood and is a more "bare bones" approach that has the goal of being easy to maintain and easy to port to other environments such as HHVM. It also aims to work with any version down to PHP 5.4.

To make the new extension easier to work with, there is an official php library available on Packagist. This library does not aim to be a drop-in replacement for the old Mongo extension. It should be noted that at the time of writing, the library doesn't implement all the features available in the old Mongo extension, such as GridFS. Hopefully we'll see a non-beta release of the extension and library soon with all the available features.

0
user956584 On

Should be relapse today with version: 1.1.0

If somebody don't have enough time to play with new extension, you can always try php library compatible with old API.

https://github.com/mongofill/mongofill

0
Walter On

Here it is a beta Version:

pecl install mongodb-beta

You need some software to compile and install:

yum -y install php-devel cyrus-sasl-devel openssl-devel gcc
echo extension=mongodb.so >/etc/php.d/mongodb.ini

composer require mongodb/mongodb

everything ok

I use CentOS 7 with PHP 7.0.1 und nginx 1.8 und Mongodb 3.2

for Windows:

http://windows.php.net/downloads/pecl/releases/mongodb/1.1.1/

2
Hari Haran On

Php 7 mongo db driver installtion

pecl install mongodb

adding extension on "php.ini"

extension=mogodb.so

Install the mongodb driver using composer on public_html directory

$ composer require alcaeus/mongo-php-adapter (or) $ php composer.phar require alcaeus/mongo-php-adapter

add at the top of index.php

require_once 'vendor/autoload.php';

3
0livier On

AFAIK, there's no compatible extension yet, but I think Hannes '@bjori' Magnusson - who works at MongoDB - wanted to work on it.

0
Clark Galgo On
pecl install mongodb

That should do it.

0
jmikola On

Version 1.1.1 of the new "mongodb" extension supports PHP 7, as does the complementary userland library.