Module configurations

As Yii2 modules may have their own config I got two examples for special cases worth considering.

Modules may have to set configuration values which do not depend into their own ‘namespace’.

It could have security implications and may confuse the user if modules can modify all config values, but they should be able to do so for a certain part, at least core components?


return array(

	'import' =>  array(

		'application.modules.user.models.*',

	),

	'modules' =>  array(

		'user' =>  array(

			'activeAfterRegister' =>  false,

		),

	),

	'components' =>  array(

		'user' =>  array(

			// enable cookie-based authentication

			'allowAutoLogin' =>  true,

			'loginUrl' =>  array('/user/login'),

		),

		'db' =>  array(

			'tablePrefix' =>  'usr_'

		),

	),

)



http://www.yiiframework.com/extension/yii-user/


return array(

	'import' =>  array(

		'application.modules.rights.*',

		'application.modules.rights.components.*', // Correct paths if necessary.

	),

	'components' =>  array(

		'user' =>  array(

			'class' =>  'RWebUser', // Allows super users access implicitly.

		),

		'authManager' =>  array(

			'class' =>  'RDbAuthManager', // Provides support authorization item sorting.

		),

	),

	'modules' =>  array(

		'rights' =>  array(

			'userIdColumn'=>'id',

			'userClass' =>  'User',

			#'install' =>  true, // Enables the installer.

			#'superuserName' =>  'admin'

		),

	),

)



http://www.yiiframework.com/extension/rights/

An alternative would be a feature for a general config auto-loading option and pattern for these to the application.

While this is also linked to another thread, I even wrote a class for this :) I hope this illustrates the problem to a little bit more.

One more use case or example: p3media.

Needs to import components from extensions and configure an image component, see config.