Closed mdeweerd closed 6 years ago
We could brainstorm to figure out what is the best way to actually add this to the main configuration file... I believe is a good idea but didn't think yet on the best approach.
I would like to get rid of all those configuration additions who make the bootstrap index.php
file so unreadable, we need to think to implement them within Yiinitializr structure. What are your thoughts?
Ok, I have to better "imagin" Yiinitializr.
While we are at it, we can also think about:
if($debugmode) {
if(isset($_GET['secretdebugkey'])) {
$config['components']['log']['routes']['xweb']['allowedIPs']=array( isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:'127.0.0.1');
}
}
Observations:
The file REGEX would be: ({$machine})?({$partialdomain}(@{$relpath}))?({$port})({$user})?({$servertype}_)?({$contexttype}).php
Theme specific configuration is in the theme path with same rule.
So, valid names, lowest precedence first, for machine 'server1', url 'www.github.com/2amigos', user 'mdeweerd' (I did not mention port in the example, I added it later),
config.php [default file first]
github.com_config.php [url before machine]
server1_com@2amigos_config.php [machine before user, after Url]
server1_github.com@2amigos_config.php
server1_github.com
github.com_mdeweerd_config.php [user after server only]
server1_mdeweerd_config.php
server1_com_mdeweerd_config.php
server1_github.com_mdeweerd_config.php
Implementation: get list of files in configuration directory matching regular expression using known machine properties. Then order the configuration files, then "merge" them with the required precedence.
In 'config.php', we could allow a special entry like this with the same naming rules: array( 'configs'=>array( 'github.comconfig'=>array(/* config /), 'server1_mdeweerdconfig'=>array(/ config *), ) );
Yiinitializr removes 'config' from the array to keep compatibility with 'Yii'. File 'server1_mdeweerd_config.php' settings have priority over 'server1_mdeweerd_config' array.
-> this allows flexibility in configuration.
So: globals.php XXXX_XXX_globals.php
with arrays: array( 'globals'=>array('YII_DEBUG'=>array('expression'=>'isset($_GET['specialdebugvar'])?1:0'),), );
I am for:
env.lock
) that can be also used for that purposecodeception
inclusion as a composer
library. lazy loading
approach at all times (apart from certain required components -ie logging)I disagree with it, Yiinitializr works with different configurations and settings (check http://yiinitializr.2amigos.us different templates and configurations). The example you provide is not compatible with current solution provided with Yiinitializr as Yii is another package downloaded with composer
, it is part of the settings you need to configure.
If we do regex, wouldn't that increase complexity to the newbies?
What I meant is that in the configuration structure, Yiinitializr itself should be configured in only one way. That is: there is only one configuration for Yiinitializr to know where to find the other configuration files.
If we do regex, this is inside Yiinitializer. Newbie only has to respect the order of naming the configuration file or option. He only writes:
server1_mdeweerd_config.php
The regex is hidden.
Can we do that through one config file only? I meant through the settings of the configuration file of Yiinitializr?
Edit: I think we should do some kind of proposal (gist maybe
?) Some of the ideas here I like them a lot
We can allow it in one config file only too - we should be flexible. If you add 'configs' to the configuration file of Yiinitializr, this is possible.
array(
'configs'=>array(
'default'=>array(
'yii'=>'yiipath',
),
'server1_mdeweerd'=>array(
'yii'=>'otheryiipath',
<restOfConfig>,
),
'domain'=>array(
'globals'=>array( 'YII_DEBUG'=>etc),
<restOfConfig>,
)
),
'Yiinitializr'=>....
)
Let's try Gist ;-).
I started a gist.
Ok, I think I identified an important misunderstanding on my behalf: Yiinitiliazr sets up the project structure and does not serve project initialisation itself.
Waht I was talking about (in part based on your goal of getting rid of the configurations in 'index.php'), is the configuration of the Yii framework after is has been 'built'/'set up'. However, this is not incompatible as Yiinitializr should set up the flexible dynamic application configuration structure with the 'index.php' that supports it.
Anyway, if this discussion spurred some ideas and future results that is a good thing ;-).
Thanks for your input @mdeweerd, there are all good ideas
@tonydspaniard I have set up a first project using Yiinitializr, so things are getting more concrete for me.
Feedback: It's probably not all Yiinitializr's fault, but I did spent some time trying to understand why my changes to 'dev.php' were not taken into account. This was due to several issues:
This also raised another possibility of improvement: to track where a configuration was coming from, I had to hack "Initializer.php". It'ld be nice if there are some helpers for debug.
Also, now that I see the use of Yiinitializr, I agree that my earlier suggestions are good ideas for Yiinitializr ;-).
Question:
Question:
Now that I am using this and that I am getting into GIT at the same time, some pull requests will probably be coming in the future.
env/dev.php is not used - instead it seems to be copied to 'env.php'.
@mdeweerd I spent some time to figure it out to myself. env.php
is generated only with the composer install
command or with the composer update
in case when env.lock
is missing (with the absent corresponding config/env.php
files).
I made a console command that removes all env.php
and env.lock
files in my project. And after that - I launch composer update
to refresh my config files. That's not suitable for me...
To keep existing structure, I suggest to generate env.php
content similar to the following:
// depends on Config::value('envlock')
return require(__DIR__.'/env/{env}.php');
// or make it dynamic
return require(__DIR__.'/env/'.Config::value('envlock').'.php');
This way - we can solve our issue with the "expired" config data.
What do you think, @tonydspaniard ?
@Borales what do you think if instead of doing so much changes we propose a new parameter to the command?
@tonydspaniard sure, we can do that, I was just thinking about BC. Your call
Adding a new parameter couldn't break anything IMHO... is just a new option case.
@tonydspaniard oh sorry, I misunderstood your previous comment. Sure, a new command parameter would be nice :)
@tonydspaniard did you mean a new command parameter to regenerate env.php
configs?
Very old ticket - no longer useful.
"Moved" from Yii extension
Could you consider adding:
Url/Server dependent configuration; Debug configuration based on Url option? I currently do stuff like this in my 'index.php':
// Determine debug mode depending on site name or get parameter (secret_dbg_key in this example):
and similar for the configuration where I have
which loads a configuration file based on the host name. "CliCheck::isCli()" checks if it is run from the command line or not. '$siteconf' gets merged with the default/common configuration.