Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have to develop 3 different sites

  1. video.com for hosting video
  2. audio.com for hosting audio
  3. docs.com for hosting docs.

domain names for example only

Almost 80% of the functionality is the same for all the three, with remaining 20% being completely different features...

How do I handle this? How does sites like SO handle this?

I am developing this in YII framework and was thinking of having these different features as modules but in this case the menu/code links in html code can become difficult.

share|improve this question
add comment

3 Answers

The way we've done it at companies I've worked at is that we have a common code line in source control. This is where that 80% of code lives. It is 100% functional and could be deployed on it's own if needed. It's like the vanilla website.

When a new website comes along that needs to build on this base, we branch the code from the common line into a new project. All customization are done in that branch with releases coming from there.

If a bug in the common code is discovered in a project, then it is fixed in the common line and then pushed to all the projects so that all projects get the fix. You never push from a project site down into common code, you always push from common code out to project sites.

As for skinning a site. Using CSS helps a lot. I follow Jeff Atwood's blog, Coding Horror, and he did a post that really helped us out. It was how I was introduced to less. It goes into how the Stack Exchange network is able to skin their sites quickly and easily.

You can find the post here. I'm not sure if there is a way to use it in php, but it's something to look into. It has been a life saver for us at my current company.

share|improve this answer
add comment

Drupal makes quick work on running multiple sites from a single codebase - http://drupal.org/node/43816

I do believe CodeIgniter also has a very good ability to build a cluster of sites using the same codebase - http://philsturgeon.co.uk/blog/2009/06/How-to-Multi-site-CodeIgniter-Set-up

share|improve this answer
add comment
  • Extract as much business functionality as possible into separate common modules (in case of our asp.net applications we use separate projects within a solution for generic logic in an application and a separate common solution for core/helper modules used across a range of a applications),
  • Do not hardcode, make things configurable either through some kind of config files or store configuration in a db. Use a separate config/db for each domain. This allows you to keep a single codebase and decide on deploy which 'flavour' of the application to use. This applies just as well to site-specific constants, db connection strings (those you obviously can't store in a db), css files to use and site content, including site navigation,
  • Break down pages into components. Use user controls or whatever the equivalent in PHP may be (turns out it's not as simple as I thought, but you might want to check this SO question). You can assemble the components as needed and reuse them between sites,

  • Use separate css files if there are vast differences in design of the sites, otherwise use the same css as a base and introduce site-specific styling using a top-level class (e.g. use .btn for base styling of buttons and .audio-com .btn or .video-com .btn for site specific styling). Using css preprocessors like LESS or SASS makes this approach feel natural. Tyanna provided a link to a blog post on the topic in an earlier answer,

  • Avoid forking the codebase. If you can't, at least make sure you have a decent working codebase before you do so. If you're writing from scratch, finish one site as a prototype, and only then fork. Having to maintain and apply bug fixes to three separate codebases is a hassle, and will only get worse as your codebases diverge with time. In general, this is a decision you shouldn't take lightly, even if it will make your life simpler for the moment. It will come back to you if/when you'll be tasked with maintaining the sites.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.