Add the following code to the folder common/config/main_local.php:
<?<span>php </span><span>return</span><span> [ </span>'components' =><span> [ </span>'mongodb' =><span> [ </span>'class' => 'yii\mongodb\Connection', 'dsn' => 'mongodb://localhost:27017/数据库名'<span> ]</span>,<span> ]</span>,<span>];</span>
The above introduces the yii framework source code and how to connect to the database mongodb in the yii framework, including the yii framework source code. I hope it will be helpful to friends who are interested in PHP tutorials.