Laravel Homestead Mongo install throws PHP undefined error: php_json_serializable_ce in Unknown on line 0

PHP Warning: starting PHP: unable to load dynamic library '/usr/lib/php/20151012/mongodb.so' - / usr / lib / php / 20151012 / mongodb.so: undefined character: php_json_serializable_ce in Unknown on line 0

After installing MongoDB, I get this error whenever I run any php command from the terminal:

php artisan

php -v

I searched for 2 days. I saw them:

PHP cannot load dynamic library (mongo.so)

https://github.com/mongodb/mongo-php-library/issues/126

and I am sure that any other solution arising from this error. They all seem to be fixes for php5 and do not work for me.

I added the extension = mongodb.so to the ini files.

I destroyed the virtual machine and started it 100 times.

I run: Rogue 1.8.5 Laravel Installer version 1.3.3

vagrant@homestead :~$ php -v PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/mongodb.so' - /usr/lib/php/20151012/mongodb.so: undefined symbol: php_json_serializable_ce in Unknown on line 0 PHP 7.0.13-1+deb.sury.org~xenial+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-1+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies with blackfire v1.14.1~linux-x64-non_zts70, https://blackfire.io, by Blackfireio Inc. 

Mongo is installed and working fine:

 vagrant@homestead :~$ mongo MongoDB shell version v3.4.0 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 3.4.0 Server has startup warnings: 2016-12-05T15:32:01.158+0000 I STORAGE [initandlisten] 2016-12-05T15:32:01.204+0000 I CONTROL [initandlisten] 2016-12-05T15:32:01.204+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2016-12-05T15:32:01.204+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2016-12-05T15:32:01.204+0000 I CONTROL [initandlisten] 2016-12-05T15:32:01.204+0000 I CONTROL [initandlisten] 2016-12-05T15:32:01.204+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2016-12-05T15:32:01.204+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2016-12-05T15:32:01.204+0000 I CONTROL [initandlisten] 2016-12-05T15:32:01.204+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2016-12-05T15:32:01.205+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2016-12-05T15:32:01.205+0000 I CONTROL [initandlisten] > 

But I can not stop this php error for anything in the world !!!

+6
source share
2 answers

I think the problem is that mongodb.so is dependent on json.so. The solution is to download mongodb.so after json.so.

I assume that you are using a custom Mongo script for Homestead. The script outputs the mongodb.so module to the php.ini file with the result that mongodb.so first loads. You must create the mongodb.ini file where mongodb.so is loaded.

Create a .ini file: /etc/php/7.0/mods-available/mongodb.ini with the content:

 ; configuration for php mongo module ; priority=30 extension=mongodb.so 

Give it a priority of 30 since json gets 20 (in my settings) to make sure it loads afterwards.

Create the ini programmatic link to / etc / php / 7.0 / fpm / conf.d to make it available to the web server.

 ln -s /etc/php/7.0/mods-available/mongodb.ini 30-mongodb.ini 

Reboot the web server and php-fpm.

 sudo service [your webserver] restart && sudo service php7.0-fpm restart 

You are done! You can configure the cli version in the same way.

+12
source

I had the same problem, I solved it by returning to an earlier version of POCL mongodb (1.1.9). Version 1.2.0 was updated on November 29 , so the mongo-php library has also been updated to version 1.1.0 .

Here is what I did:

 sudo pecl uninstall mongodb sudo pecl install mongodb-1.1.9 composer update 

The pecl commands will display the same warning, but the installation was completed successfully.

I hope the mongo-php library will be fixed soon, so we don't get stuck with the older PECL extension.

+3
source

Source: https://habr.com/ru/post/1012910/


All Articles