A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearWhat do you think about this weird idea about how to configure development/staging/production instances? - page 1
User InfoPosts
What do you think about this weird idea about how to configure development/staging/production instances?#1
I just got a weird idea about how to configure environment-dependent parameters. Sort of like parameters you can find in Rails' config/database.yml

In my current project I use PHP and Litespeed Web Server (though the same technique applies to PHP + Apache), and I thought... 'why not use mod_rewrite for this?'. I have separate virtual hosts configs for each env (development/production at the moment)

What I have now is:



RewriteRule (.*) $1 [env=development:1]




for the development environment vhost. But what if it will be something like this?



RewriteRule (.*) $1 [env=development:1,env=mysql_host:localhost,env=mysql_port:3306,env=mysql_user:root,env=mysql_pass:,env=mysql_db:mydbname]




Would it make sense or will cause some problems? What do you think?

posted date: 2008-12-14 02:04:00


Re: What do you think about this weird idea about how to configure development/staging/production instances?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-14 02:04:01


Re: What do you think about this weird idea about how to configure development/staging/production instances?#3
I don't believe rewrite rules are a particularly intuitive place to put configuration information like that. Maybe I am misunderstanding something, but is the only difference between the development, staging, and production environments the database connection? Typically the code is also different (at least once changes are made), and so if you are using a revision control system, I think it might be a better idea to have a template configuration file (database.cfg.template) that you copy (and tell your revision control system to ignore) and modify (to database.cfg). Then it's obvious where this information is.

posted date: 2008-12-14 02:56:00


Re: What do you think about this weird idea about how to configure development/staging/production instances?#4
yeah, I certainly understand what you are saying — I've been doing this for years (config files, etc.) I also do you revision control, of course (git), though the point is that my virtual host config files are in repo as well. I just never thought about this way to specify some sort of config.. :)

posted date: 2008-12-14 03:07:00


Re: What do you think about this weird idea about how to configure development/staging/production instances?#5
You're right -- it's a wierd idea.IMO, this is a really bad use for mod_rewrite. True, the configuration information belongs with the machine, rather than the codebase (a mistake I see people make all the time), but it doesn't necessarily belong with the webserver configuration, either.I would recommend a configuration file that is not managed by version control.

posted date: 2008-12-14 15:51:00


Re: What do you think about this weird idea about how to configure development/staging/production instances?#6
atm I ended up with config file AND RewriteRule (.*) $1 [env=development:1] only

posted date: 2008-12-14 18:15:00


Re: What do you think about this weird idea about how to configure development/staging/production instances?#7
If you want to set the environment in the vhost you can do something likephp_value ENV "development"And then read it from the $_SERVER array

posted date: 2008-12-20 22:25:00


Re: What do you think about this weird idea about how to configure development/staging/production instances?#8
First of all, if you're not actually changing the URL, don't use $1 as the replacement, just use a dash. As per the docs:A dash indicates that no substitution should be performed (the existing path is passed through untouched). This is used when a flag (see below) needs to be applied without changing the path.But really, I think the answer is mod_env. SetEnv directives could be placed within your <VirtualHost> blocks, avoiding the unnecessary RewriteRule foo.

posted date: 2009-01-01 20:23:00


Re: What do you think about this weird idea about how to configure development/staging/production instances?#9
The best and only place where you should define current environment is bootstrap.Look at symfony or agavi bootstrapping files.

posted date: 2009-01-02 00:08:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.