Welcome Guest, Not a member yet? Register   Sign In
Separating Config Directory from Application?
#1

[eluser]JasonS[/eluser]
Hi,

I want to run multiple websites from the same base. In order to do this I want to separate the config folder from the applications folder.

A website install would thus look like this.

index.php // CI Index
/config // Application/config

Does anyone know how many changes are required to make this happen and where such changes need to made?

Thanks
#2

[eluser]pickupman[/eluser]
config folder is set in /system/libraries/Common.php (1.7.2) or /system/core/Common.php(2.0dev). You can extended this class to point to another folder. Another option is use something like

config.php
Code:
require_once(__FILE__ .'../../config/config.php');

Let it read up the folder tree to use your system wide config file. Option 2 maybe better as you would be able to place application specific config files into each of their respective config folders, but have one master config.php file for setting system settings.
#3

[eluser]JasonS[/eluser]
Common.php is a collection of functions. Does this mean I would need to edit the core to achieve this?
#4

[eluser]JasonS[/eluser]
I am also open to other ideas on how to create multiple sites using the same base.

The main issue is that if I have tens or hundreds of websites how do I update them all. They will have shared application/system folders and custom databases. Seems that separating the config file is the most logical solution. Am I at least right with this conclusion?
#5

[eluser]pickupman[/eluser]
[quote author="JasonS" date="1284406149"]Common.php is a collection of functions. Does this mean I would need to edit the core to achieve this?[/quote]

No, do not edit core files. Refer to the user guide for extending a class. See section [url="http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html"]Extending Native Libraries[/url]. You only need to recreate the methods you need to modify. That's one of the strong features of CI.
#6

[eluser]JasonS[/eluser]
[quote author="pickupman" date="1284408049"][quote author="JasonS" date="1284406149"]Common.php is a collection of functions. Does this mean I would need to edit the core to achieve this?[/quote]

No, do not edit core files. Refer to the user guide for extending a class. See section [url="http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html"]Extending Native Libraries[/url]. You only need to recreate the methods you need to modify. That's one of the strong features of CI.[/quote]

Perhaps you misread my previous post.

[quote author="JasonS" date="1284406149"]Common.php is a collection of functions. Does this mean I would need to edit the core to achieve this?[/quote]

It isn't a class, it is a collection of functions and as such if you redefine an existing method you will get errors.
#7

[eluser]JasonS[/eluser]
Does anyone have an answer for this? Is it a case of editing these core common functions? Is there another way?
#8

[eluser]danmontgomery[/eluser]
I'm not sure I understand... You want multiple websites to share the same config directory? Or you want websites to share all of the same code EXCEPT the config directory?
#9

[eluser]pickupman[/eluser]
Oops, you are right. It's weird that it was not a class. Perhaps, the include route would be best. Otherwise modify the core files, and remember to fix when you upgrade CI.
#10

[eluser]Bas Vermeulen[/eluser]
Hi,

What I did to have multiple sites running on one install is the following:

- index.php
- .htaccess
- system
- application (including the config folder)
- site1
-- index.php
-- .htaccess
-- public
- site2
-- index.php
-- .htaccess
-- public

site1 and site2 come with just an index.php and a .htaccess file and a public folder with images and css files. In the index.php files you can set the location of the system and application folders. In the same index.php file you can also add config items, these will overwrite the config in the application/config folder:

/site1/index.php
Code:
$assign_to_config['base_url'] = 'http://localhost/site1';
/site2/index.php
Code:
$assign_to_config['base_url'] = 'http://localhost/site2';

To be able to use a custom database connection per site I added the following to the index.php files:

/site1/index.php
Code:
define('DB_GROUP', 'site1');
/site2/index.php
Code:
define('DB_GROUP', 'site2');

In the application/config/database.php I set:

Code:
$active_group = DB_GROUP;

Then you can add the connection groups in the same file:

Quote:$db['site1']['hostname'] = "localhost";
$db['site1']['username'] = "username";
$db['site1']['password'] = "password";
$db['site1']['database'] = "database";
$db['site1']['dbdriver'] = "mysql";
$db['site1']['dbprefix'] = "";
$db['site1']['pconnect'] = TRUE;
$db['site1']['db_debug'] = TRUE;
$db['site1']['cache_on'] = FALSE;
$db['site1']['cachedir'] = "";
$db['site1']['char_set'] = "utf8";
$db['site1']['dbcollat'] = "utf8_general_ci";
$db['site1']['swap_pre'] = "";
$db['site1']['autoinit'] = TRUE;
$db['site1']['stricton'] = FALSE;

I hope this is what you were looking for?




Theme © iAndrew 2016 - Forum software by © MyBB