Class 'MongoId' not found in Laradock application

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.

  • Jenkins not able to access internet when running as docker container
  • Docker swarm on 'dind' images and networking problems
  • How should I launch ipython notebook from Docker once a session has been launched?
  • OS X - how to give permissions to jenkins user to run docker command
  • kubernetes : PTY allocation request failed
  • Cron job not auto runs inside a Docker container
  • 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?

  • “gnustep-config --objc-flags” no output
  • s3 mounted inside the container. how to expose it to the host?
  • docker-machine env default | eval “$(docker-machine env default)” | unable to run command docker
  • Communicating between docker containers
  • Developer environment - how to call/consume other micro services
  • Online image building service for Arduino using Rails
  • One Solution collect form web for “Class 'MongoId' not found in Laradock application”

    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

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.