symfony: creating individual modular sites with a base configuration..
Tuesday, May 22nd, 2007Ok, so a current project i’m working on is rolling out potentially hundreds of sites..
All of these sites are using the same base, but have different configuration, design and data for each one..
A problem has been how to roll all these sites out, while keeping them easy to update with bug fixes and modifications..
Here’s my solution..
Firstly we start with the config files.. app.yml and view.yml are very site individual, so what do you do if you want some site specific settings?
Well, in your app/config folder, create an app_local.yml and a view_local.yml - these will be your local config files, while the app.yml and view.yml contain settings that are the same for all of your sites…
Here’s an example of how the app.yml and app_local.yml would work from my sites..
all:
#parameters for the gallery and avatar directories and sizes
galleries:
size_limit: 30
limit: 20
gallery_count: 25
upload_dir: < ?php echo sfConfig::get('sf_web_dir')?>/images/media/galleries/uploads
allowed_image_types: [image/jpeg, image/jpg, image/pjpeg, image/gif, image/png, image/bmp, image/tiff]
allowed_video_types: [video/mov, movie/quicktime, video/mpeg, video/x-ms-asf, video/x-msvideo, video/x-ms-wmv]
And here’s my app_local.yml
prod:
#MUST EDIT THESE PARAMETERS - FOR PRODUCTION ONLY
site_name: Skeleton Site
cookie: skeleton
site_domain: skeleton.com
site_support_email: support@< ?php echo sfConfig::get('app_site_domain')?>
merchant:
id: 4
pass: password
all:
#SHOULD EDIT THESE PARAMETERS
#the selected attributes for the member profiles - eg, what profile questions to ask.. refer to db
member:
attributes: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
swf:
heading_font: DeliciousHeavy
Ok.. so hopefully the division is starting to make sense…
Now we need to configure the handlers… This part requires some small hacks of the symfony core files..
lets start with app.yml (note the paths are my personal nix paths.. im presuming you know where your symfony core files are)
open up /usr/local/lib/php/symfony/symfony.php and at around line 97, add this in:
if ($file = $configCache->checkConfig($sf_app_config_dir_name.'/app_local.yml', true))
{
include($file);
}





