yii2 mongodb installation
- By Preneesh AV --
- 13-Jun-2019 --
- 147 Comments
Yii2 mongodb installation
To use mongodb in yii2 application we need to install php extension for mongodb. this can be done using below command on ubuntu os.
sudo apt-get install php-mongodb
Download composer file and install the extension in the root folder of yii2 project
php composer.phar require --prefer-dist yiisoft/yii2-mongodb
Configuration
To use this extension, simply add the following code in your application configuration:
'class' '\yii\mongodb\Connection','
dsn' 'mongodb://@localhost:27017/mydatabase','options' "username" "Username","password" "Password" ] ], ],];