开发者

Is there a scalable multi-site strategy with codeigniter?

I've been looking for a effici开发者_运维问答ent and secure way of enabling multi-site capabilities to codeigniter for a while.

These two(one & two) articles I found pretty interesting, but they don't seem to offer a scalable way of doing it. Of the two, John Dennis Pedrie's(link two) method seemed to be more thought out for our purposes.

However, say you have 100, 500, or 1000 separate sites, is this method still the best to go? Ie. would having 500 separate db config files in a folder and updating them with php be the best way to go?

Another method I can see being useful is a database of config options. Update the DB and you could have another site come online. However that would require storing all the database usernames and passwords in cleartext. Can't see that going over well.

Any answers, advice, tips, or interesting thoughts?


We can do something like this.

In config.php file, we can define the base_url as

$protocol = preg_split('[/]', $_SERVER["SERVER_PROTOCOL"]);

$http_protocol = strtolower($protocol[0]) . "://";

$config['base_url']     = $http_protocol . $_SERVER["HTTP_HOST"]. "/" ;

We can create the database using domain name prefixed and separated by underscore and have the setting done.

In database.php file as follows

$db['default']['hostname'] = 'localhost';

$db['default']['username'] = 'xxxxxxxx';

$db['default']['password'] = 'xxxxxx';

$db['default']['database'] = $_SERVER["HTTP_HOST"] . '_thedatabasename';


Maybe you could find an answer in the HMVC (Hierarchical Model View Controller)

There are modular extentions for Codeigniter you can find some here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜