Closed sokil closed 7 years ago
Yii2 support should be there because there is no good mongo client library for yii2, yii2-mongo is not itself flexible and doesn't support the flexibility of noSQL databases for example: when you want to use multiple collections for same type of document which varies for each user.
implemention for yii2 currently in plans
Great, when it is going to be published?
currently this task is not a priority, but pull requests always welcomes here https://github.com/sokil/php-mongo-yii or here https://github.com/PHPMongoKit/yii2-mongo-odm
by the way why you currently can't use https://github.com/sokil/php-mongo directly in yii2 app?
@sokil I have managed to modify this lib to use on my Yii2, I can contribute to this repository but I am a kind of newbie in using github so I don't know how to make pull request or simple how to contribute to any git repository...
fork this repo, do changes, push to your fork, and create pull request here from https://github.com/sokil/php-mongo-yii/pulls
\CApplicationComponent optional and i don't use it, so i can simply remote it and adapter may be registered inside yii2 service locator, right?
What I did is, I just changed the \CApplicationComponent
to yii\base\Component
, Yii::app()
to Yii::$app
and it did work...
but now another problem is coming as I removed the pecl/mongo
deprecated package and installed pecl/mongdb
1.2.2, it is giving error Class MongoClient not found
... I will open a new issue on php-mongo repo..
no, this lib has no support of new mongo extenstion
ok, I found this issue already there https://github.com/sokil/php-mongo/issues/115
https://github.com/PHPMongoKit/yii2-mongo-odm - check this, written on the fly... )
Ok you removed the Yii2 logger part and made an independent class, great... I am thinking of setting errors key (as it is there in Yii2) if validation failed instead of throwing an exception...
https://github.com/sokil/php-mongo/blob/master/src/Document.php#L610-L628 - Document::validate() throws Exception
Use Document::isValid() && Document::getErrors() to get errors instead of exception
Ok, I would need to check Document::isValid()
before saving document with Document::save()
to prevent it from throwing exception...
correct. there are two equal cases:
if ($document->isValid())
$document->save();
} else {
var_dump($document->getErrors());
}
or
try {
$document->save();
} catch (\Sokil\Mongo\Document\InvalidDocumentException $e) {
var_dump($document->getErrors());
}
https://github.com/PHPMongoKit/yii2-mongo-odm - Yii2 adapter for mongo client implemented
:+1: