27

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?

markz
  • 1,766
  • 2
  • 14
  • 15

7 Answers7

14

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

jmikola
  • 6,892
  • 1
  • 31
  • 61
6

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

0livier
  • 478
  • 4
  • 7
  • A stable version working for PHP 7 has been released a few weeks ago. See the releases history at [its pecl page](https://pecl.php.net/package/mongodb) or [the code on Github](https://github.com/mongodb/mongo-php-driver). – 0livier Dec 14 '15 at 13:29
  • It lists php version 5.99.99 as the highest version it supports. I do not see a PHP7 version at the provided links. Please provide a direct link to a version that supports PHP7. Thank you. – Reinier Dec 22 '15 at 14:43
  • [Version 1.1.1](https://pecl.php.net/package/mongodb/1.1.1) introduces support for PHP 7. – jmikola Dec 26 '15 at 04:11
3

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.

Rexxars
  • 1,167
  • 8
  • 10
1

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

MartyIX
  • 27,828
  • 29
  • 136
  • 207
user956584
  • 5,316
  • 3
  • 40
  • 50
0

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/

Walter
  • 1
  • 1
-1
pecl install mongodb

That should do it.

-1

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';

  • 4
    Please don't add the same answer to multiple questions. Answer the best one and flag the rest as duplicates. See http://meta.stackexchange.com/questions/104227/is-it-acceptable-to-add-a-duplicate-answer-to-several-questions – Bhargav Rao Nov 05 '16 at 10:09
  • To install Php 7 mongo db driver installation you can follow https://github.com/mongodb/mongo-php-library hope it will solve your problem. – RASEL RANA Feb 27 '17 at 10:58