• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
multiple sites, 1 codebase, using symlinks (with smarty)

#11
[eluser]Unknown[/eluser]
I'm wondering if anybody using this setup as come up with a way to define separate routes for each site? Any ideas on how I might go about achieving this dream?

I have this solution setup using lighttpd and works great! Thanks for taking the time to share this with the community!

#12
[eluser]Vince Stross[/eluser]
I use a similar architecture with a single code base and sym links, etc. I've updated the index.php file for each site to include additional constant variables:

Code:
define('JASMINEROOT', $_SERVER['DOCUMENT_ROOT']);
define('JASMINEPATH', JASMINEROOT."/application");

The "/application" folder is an extremely slimmed version of a default "application" folder. I do not call mine "application" for security reasons but for this post I changed it for clarification purposes. This folder has a "views" folder for custom views for this site and a "config" folder. In the config folder I have all the config files from a standard CI install. In order for the custom config for each site to work I have to change the config files in the core code base "application/config" folder as follows:

Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

if(defined('JASMINEROOT')){include_once(JASMINEROOT.'/rabbit_hole/config/config.php');}

else{

/*

|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|    http://www.your-site.com/
|
*/
$config['base_url']    = "http://www.domain.com/";

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = "index.php";

/*
.... rest of config.php ....

}

?>

You can do this with any of your config files, including routes.php

Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

if(defined('JASMINEROOT')){include_once(JASMINEROOT.'/rabbit_hole/config/routes.php');}
else{
/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
|     www.your-site.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
|    http://ellislab.com/codeigniter/user-guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There are two reserved routes:
|
|    $route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
|    $route['scaffolding_trigger'] = 'scaffolding';
|
| This route lets you set a "secret" word that will trigger the
| scaffolding feature for added security. Note: Scaffolding must be
| enabled in the controller in which you intend to use it.   The reserved
| routes must come before any wildcard or regular expression routes.
|
*/
$route['default_controller'] = "home";
$route['scaffolding_trigger'] = "";
}

?>

So in other words: I can load my codebase as a site in itself, or I can call it from another site. If I am calling it from another site, the constants are set and each config file will check for the constants and if exist, load the config files from the appropriate site.

Hope this helps!

#13
[eluser]Myles Wakeham[/eluser]
Very interesting thread. Thanks to all for investing the time on it.

We share some similarities.... We too have our own boxes colocated, but we have 6 servers. And we also have some clients that prefer to run our code on their boxes and take care of their own hosting. Oh, and we also have development machines (our own personal laptops), a testing/staging platform on Fedora Core 5, and then there's all the production platforms.

The first challenge is in handling the migration from dev to test. That's not too bad because we all use Dreamweaver and we simply have the testing system as the deployment site and we just migrate all the files to that site. But then when a rev has to be moved to production, we have scripts that we have written that FTP the files to a predetermined folder structure on each production environment. Unfortunately the production environments can't share a folder with common code, so we have to manually duplicate the entire CI framework on each server. However if a single server runs multiple PHP apps that use CI, its conceivable that we could share a common code base there. The problem isn't technical, however. The problem is that each application needs to be tested and validated before being moved to production, and if there is a common problem in CI that all share, then all are affected. Its easier for us to validate each production system independently rather than hope that what works in one CI instance, will work just fine in all the other apps that share that code base.

Then it gets even more complex. We have developers in multiple countries around the world. They all have to check in their code to CVS before it gets moved to test. This not only includes PHP code, but SQL scripts for Firebird (our chosen SQL database platform). Also there are the HTML, Javascript, CSS and other files that all go together to make one system wholesome. Oh, and yes we use Smarty extensively as well.

I'm not trying to overload this thread, but my suspicion is that the original poster may well be on a journey towards the same end as we are and may in fact encounter these configuration management issues at a bigger scale shortly.

Myles

#14
[eluser]Techno Heart[/eluser]
Will u explain this clearly.. i have the same requirement actually.. i can understand the hierarchy you mentioned. but where to place the global application folder exactly...


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.