cakephp-monga icon indicating copy to clipboard operation
cakephp-monga copied to clipboard

Error at Access to a collection

Open ghost opened this issue 7 years ago • 7 comments

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

ghost avatar Jun 02 '17 16:06 ghost

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

LeWestopher avatar Jun 21 '17 21:06 LeWestopher

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

swapnilbijwe avatar Jul 27 '17 12:07 swapnilbijwe

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"

rahulTheDev avatar Aug 01 '17 07:08 rahulTheDev

+1

richard015ar avatar Aug 23 '17 23:08 richard015ar

Same error here on CakePHP 3.5, any ideas ?

benoitkopp avatar Oct 17 '17 13:10 benoitkopp

@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.

LeWestopher avatar Oct 18 '17 23:10 LeWestopher

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

shashi-r-mishra avatar Feb 20 '18 12:02 shashi-r-mishra