Yii Framework Forum: Configurations and environments - Yii Framework Forum

Jump to content

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

Configurations and environments

#1 User is offline   CGeorge 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 27-May 10
  • Location:Spain

Posted 07 October 2011 - 01:45 AM

I find RAILS environment system very useful, and I have been using my own implementation on Yii:
  • I have a base configuration for all the environments.
  • Then, I merge it with the specific environment configuration.
  • Finally, I merge it with the local configuration.
So this is my base config folder for all my projects:
config/
   base.php
   local.php
   development.php
   production.php
   console.php


I would like to see Yii providing an easy way of doing this without the dirty CMap::mergeArray() calls inside the config files. This feature should not be enabled by default because it is less flexible.

I usually define the environment on the index.php / yiic.php

Optionally: For very complex applications I use folder-based configurations with a bootstrap script that merges all the files of the folder in a single array, saving it in the cache.
0

#2 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,588
  • Joined: 17-January 09
  • Location:Russia

Posted 07 October 2011 - 09:55 AM

CGeorge
I'm developing this way as well but using CMap::mergeArray() doesn't look dirty to me.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#3 User is offline   CGeorge 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 27-May 10
  • Location:Spain

Posted 07 October 2011 - 01:13 PM

View Postsamdark, on 07 October 2011 - 09:55 AM, said:

CGeorge
I'm developing this way as well but using CMap::mergeArray() doesn't look dirty to me.




Ok
Then I propose adding this environment configuration by default to the advanced config I proposed here Posted Image
0

#4 User is offline   schmunk 

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

Posted 07 November 2011 - 07:18 AM

Another thing I often stumbled upon with configurations is the problem that I have to set values, which rely on a Yii method, eg. Yii::app()->baseUrl, this is often needed for extensions (e.g. CSS or JavaScript includes). If I do not publish them via assetManager.

'extensionXY' => array(
  'scriptUrl' => Yii::app()->baseUrl.'/path/to/javascript.js'
)

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

#5 User is offline   CGeorge 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 27-May 10
  • Location:Spain

Posted 08 November 2011 - 01:56 AM

View Postschmunk, on 07 November 2011 - 07:18 AM, said:

Another thing I often stumbled upon with configurations is the problem that I have to set values, which rely on a Yii method, eg. Yii::app()->baseUrl, this is often needed for extensions (e.g. CSS or JavaScript includes). If I do not publish them via assetManager.

'extensionXY' => array(
  'scriptUrl' => Yii::app()->baseUrl.'/path/to/javascript.js'
)



I think that application properties should be used after the config definition. For example:


#config/main.php
'extensionXY' => array(
    'scriptUrl' => 'path/to/javascript.js'
)

#extensions/XY.php
public function init() {
    if($this->scriptUrl is a relative path)
     	$this->scriptUrl = Yii::app()->baseUrl.'/'.$this->scriptUrl;
        ...
    }

0

#6 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 08 November 2011 - 04:54 AM

I'm also using CMap to merge configs and is fine.

@schmunk , in 2.0, aliases will be more flexible allowing this kinda of usage
--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

#7 User is offline   sidewinder 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 216
  • Joined: 08-July 09
  • Location:Poland

Posted 08 November 2011 - 05:51 AM

I'm using this extension. It does a fantastic job managing my configuration files.
---------------------------------------------------------------------
"Never memorize what you can look up in books."
Albert Einstein
0

#8 User is offline   schmunk 

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

Posted 08 November 2011 - 09:28 AM

View PostGustavo, on 08 November 2011 - 04:54 AM, said:

@schmunk , in 2.0, aliases will be more flexible allowing this kinda of usage

Also for URLs not only local paths?
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