Welcome Guest, Not a member yet? Register   Sign In
multiple sites, 1 codebase, using symlinks (with smarty)
#1

[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
site #2: has both frontend and backend applications
     (will also operate on wildcard sub-domains)
site #3: uses ssl with one application
site #4: one application (internal access)

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/
    my global application folder, where most the code goes
CodeIgniter_1.5.4/
    my CI installs system folder and other files, I leave the version
    number so that I can link to a new system in the index.php if
    needed for testing
common/
    an apache directory alias called common lets me link to subfolders here
    called img, js, css, file, etc. Having one folder with all my includes makes
    it easy to specify in an .htaccess file that CI should leave links alone with
    the word common in it.
Smarty_2.6.18/
    my smarty install, contains the actual libraries
www_site1/
    the site root for site #1
www_site2/
    the site root for site #2
www_site3/
    the site root for site #3
www_site4/
    the site root for site #4


Messages In This Thread
multiple sites, 1 codebase, using symlinks (with smarty) - by El Forum - 07-14-2007, 12:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB