multiple sites, 1 codebase, using symlinks (with smarty) |
[eluser]CodeOfficer[/eluser]
Greetings all, First, I'd like to say thanks for making a great framework, its flexible and fun to use! I've only been at it a few days but am very impressed. I even managed to get Smarty templates integrated with very little trouble. (not required I know but was my preference) Now onto the meat ... MY REQUIREMENTS My project called for a specific configuration of sites and applications: Code: site #1: one application All 4 sites are heavily related ... and will often want to use the same models, libraries, helpers, views etc. Unfortunately CI doesn't give me a place to store these resources cross-application, and I really didn't feel comfortable editing or extending the core CI classes. That might have made upgrading the framework painful with later releases. I like the idea of just 'dropping in' a new system folder without worry. MY HOMEWORK (B-) So as I was looking into CI initially, I found a lot of posts about running multiple-application sites. Overall, I got the impression that this was something CI 'could' do with tweaking (depending on your specific sites/applications) but wasn't particularly great at out of the box. Thankfully, CI is so easy to work with that there are a number of solutions to consider. Option 1: One alternative was to run all my apps out of the same application folder, and just give them unique controllers ... I considered this but thought it might be difficult to keep site #1 from calling site #2's controllers by editing the urls. My sites needed to be fairly secure in this regard. Option 2: Another alternative was to modify the loader of the CI core classes to include a new search path, essentially adding a Library level where cross-application code goes. This would have been the most attractive option if I felt more comfortable editing core files. But I don't ... ick! Hopefully CI adopts a similar solution officially in a later release. Some related links on that method: http://www.jaaulde.com/test_bed/CodeIgniter/modLoader/ http://ellislab.com/forums/viewthread/49157/ And other options I won't get into right now ... MY BACKGROUND INFO My situation is unique to me perhaps. I happen to own the box my sites are being hosted on, so all configuration options are available. My sites use the traditional php5, mysql5, apache2 on Free(as in beer)BSD. I can edit httpd.conf freely and create .htaccess files as needed. MY SOLUTION I found I was able to share a (parent) application folder (located outside each site's root) with a specific site's (local) application folder ... I did this by creating a series of symbolic links in each (local) application folder to represent the corresponding folders in my (parent) application folder ... I literally matched symbolic links to parent folders exactly ... EXCEPT for the (local) application's 'controllers' folder, which was really the meat of each website. It might be easier to show you the following folder hierarchy I used: Code: application/ |
Welcome Guest, Not a member yet? Register Sign In |