PHP Fatal error: class "MongoDate" not found

I am using a lithium console (lithium / console / li3) to run some command, and I get this error:

PHP Fatal error: Class 'MongoDate' not found

Details of my system:

  • mongodb server: 2.6.1
  • php mongodb client: 1.5.2
  • apache 2.4.7
  • php 5.5.9-1ubuntu4

$Requests = Requests::find('all', array('conditions'=>array( 'expired'=>array('<'=>new \MongoDate(time())), 'processed'=>0 )));

I do not have this error when running this code in the old version

  • PHP Version 5.3.10-1ubuntu3.11
  • Apache Server / 2.2.22 (Ubuntu)
  • Mongodb client: 1.4.5
  • Mongodb server: 2.4.10

Thank.

One more thing: I'm trying to create a simple script.

$date = new MongoDate();

it works without problems through a web server (browser), but if I use the php command to run this file, I get the same error: Class 'MongoDate' not found Therefore, I believe that this is a problem with the php command.

+4
source share
2

, mongodb .

var_dump(extension_loaded('mongodb'));

, php.ini.

+3

, PHP 7, :

MongoDate MongoDB\BSON\UTCDateTime

, , miliseconds , , 1000, :

$date = new \MongoDB\BSON\UTCDateTime(strtotime('yesterday') * 1000);
+9

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


All Articles