Yii Framework Forum: Module configurations - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Module configurations

#1 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 569
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 17 October 2011 - 04:02 PM

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.yiiframew...nsion/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.yiiframew...tension/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.
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#2 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 569
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 19 October 2011 - 05:46 AM

One more use case or example: p3media.
Needs to import components from extensions and configure an image component, see config.
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users