Why Yii2 module separate configuration does not work in basic app? -


i have yii2 basic application 2 parts (web , service mobile).

i have created module handle restful requests fired mobile . want configure module rest. created config file module in side module directory. mentioned in yii2 documentation modules

/config/config.php:

return [  'components' => [   'urlmanager' => [         'class' => 'yii\web\urlmanager',         // disable index.php         'showscriptname' => false,         // disable r= routes         'enableprettyurl' => true,         'enablestrictparsing' => false,         'rules' => array(              [                 'class' => 'yii\rest\urlrule',                 'controller' => 'mobile/mobile-clients',                 'extrapatterns' => ['get search' => 'search']             ],          ),     ],     'request' => [         'class' => '\yii\web\request',         'enablecookievalidation' => false,         'parsers' => [             'application/json' => 'yii\web\jsonparser',         ],     ], ]  ]; 

the module class follows:

<?php  namespace app\modules\mobile;  use yii; use yii\base\module;  class mobileservice extends module {       public $controllernamespace = 'app\modules\mobile\controllers';       public function init() {          parent::init();               yii::configure($this, require(__dir__ .directory_separator                         .'config'.directory_separator .'config.php'));       } }          

the problem request component not working expected while works fine when configured in application configuration (config/main.php)

same urlmanager.

any ideas?

the solution problem create api application new application inside yii2 basic app. shares models , vendors directory has own configuration , entry script (index.php). solution link more information .

edit:

do not forget add user component in api.config file

  'user' => [   'identityclass' => 'app\models\user',   'enableautologin' => false,   ],  

i think using yii2 advanced application structure better case mine. solution works perfect :) .

best.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -