包含yii2-advanced模板和mongoDB的{api}文件夹

时间:2015-07-22 09:29:36

标签: mongodb api yii2-advanced-app

我想用mongoDB和yii2-advanced模板开发API。我发现APImysqlapi-config集成mongoDB。但我想用api\config\main.php创建它。
我在<?php use \yii\web\Request; $params = array_merge( require(__DIR__ . '/../../common/config/params.php'), require(__DIR__ . '/../../common/config/params-local.php'), require(__DIR__ . '/params.php'), require(__DIR__ . '/params-local.php') ); $siteUrl = "http://192.168.1.183"; return [ 'id' => 'app-api', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'modules' => [ 'v1' => [ 'basePath' => '@app/modules/v1', 'class' => 'api\modules\v1\Module' ] ], 'components' => [ 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [] ], 'user' => [ 'identityClass' => 'common\models\User', 'enableAutoLogin' => false, ], 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning'], ], ], ], 'mongodb' => [ 'class' => '\yii\mongodb\Connection', 'dsn' => 'mongodb://localhost/advanced_yii', ], ], 'params' => $params, ]; ?> 文件中更改了以下内容:

CountryController.php

<?php namespace api\modules\v1\controllers; use yii\rest\ActiveController; /** * Country Controller API */ class CountryController extends ActiveController { public $modelClass = 'api\modules\v1\models\Country'; public function actionTest() { echo "testing"; } } ?> 档案中:

'http://192.168.1.183/advanced/api/web/v1/test

但是当我在网址中写page not found时,它会给我stderr错误。

0 个答案:

没有答案