LeWestopher / cakephp-monga

A CakePHP 3.x plugin for accessing MongoDB NoSQL data stores
MIT License
17 stars 3 forks source link

Error at Access to a collection #10

Open ghost opened 7 years ago

ghost commented 7 years ago

Hello, I'm getting a Fatal error: Class 'App\Model\MongoCollection\UsersCollection' not found in ..cake3test/vendor/lewestopher/cakephp-monga/src/MongoCollection/CollectionRegistry.php on line 85

i've changed the Namespace to test as CollectionRegistry::setNamespace('App\Model\AlternativeCollectionLocation\');

and i got the same error

LeWestopher commented 7 years ago

@rroja Can you tell me a little more about the error? What version of cakephp-monga are you running? Version of Cake? Thanks!

swapnilbijwe commented 7 years ago

Class 'MongoClient' not found got this for
$cake_monga = ConnectionManager::get('mongo_db'); $mongodb = $cake_monga->connect();

rahulTheDev commented 7 years ago

It is version cakephp 3.4.11 and download the latest cakephp-mongo. Still having the same error. "Hello, I'm getting a Fatal error: Class 'App\Model\MongoCollection\UsersCollection' not found in ..cake3test/vendor/lewestopher/cakephp-monga/src/MongoCollection/CollectionRegistry.php on line 85

i've changed the Namespace to test as CollectionRegistry::setNamespace('App\Model\AlternativeCollectionLocation\');

and i got the same error"

richard015ar commented 7 years ago

+1

benoitkopp commented 7 years ago

Same error here on CakePHP 3.5, any ideas ?

LeWestopher commented 7 years ago

@richard015ar @BenoKop @rahulTheDev

Sorry for the late reply on this - I think I've discovered your issue. I never expected custom namespaces to be a popular feature, I just wrote it in to easily be able to test mocked collection classes. Because of this, the string format for setting the namespace is a non-standard format. To properly set a new namespace for your collection classes:

  1. Use double back-slashes, EG: \
  2. Trail the namespace with another double back-slash.

Such as:

CollectionRegistry::setNamespace('App\\Model\\AlternativeCollectionLocation\\');

Since this has been brought to my attention, I will standardize the namespacing in 0.6, so be aware of that.

shashi-r-mishra commented 6 years ago

While using $mongoAdapter->connect(); it says MongoClient not found.

CAKEPHP 3.5.12 Mongo db version v3.2.19

Exception: Class 'MongoClient' not found in [/mnt/d/www/html/cronRevamp/vendor/league/monga/src/League/Monga/Connection.php, line 54] 2018-02-20 12:13:55 Error: [Error] Class 'MongoClient' not found in /mnt/d/www/html/cronRevamp/vendor/league/monga/src/League/Monga/Connection.php on line 54