Class 'MongoId' not found in Laradock application
Asked Answered
E

1

6

Using Laradock (basically a set og Docker images for Laravel development), I keep getting Class 'MongoId' not found FatalThrowableError errors when calling new \MongoId( $id ) in PHP.

This post Class 'MongoId' not found (Zend Framework with MongoDB Doctrine) suggests that the reason for given error is that the PHP Mongo extension isn't enabled.

However, if I look at the phpinfo() output, I can see mongodb section. Doesn't that mean it's enabled?

What else could possibly cause this error?

Epirogeny answered 8/8, 2016 at 12:35 Comment(0)
R
16

I assume that you are using php 7 version.

In php 7 version a new MongoDB extension is used.

So instead of legacy MongoId you should use MongoDB\BSON\ObjectID

Racial answered 8/8, 2016 at 13:10 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.