管理多個(gè)應(yīng)用?
默認(rèn)情況下,我們假設(shè)你只是用CodeIgniter來(lái)管理一個(gè)應(yīng)用,并將該應(yīng)用在 application 目錄下進(jìn)行構(gòu)建。 然而也存在這樣的可能性:多個(gè)應(yīng)用共享一個(gè)CodeIgniter的安裝目錄,甚至開(kāi)發(fā)者會(huì)將 application目錄進(jìn)行重命名或移動(dòng)位置。
重命名或遷移應(yīng)用程序目錄?
如果你想重命名你的應(yīng)用文件夾或者移動(dòng)
it to a different location on your server, other than your project root, open
your main app/Config/Paths.php and set a full server path in the
$appDirectory
variable (at about line 38):
public $appDirectory = '/path/to/your/application';
You will need to modify two additional files in your project root, so that
they can find the Paths
configuration file:
/spark
runs command line apps; the path is specified on or about line 36:require 'app/Config/Paths.php'; // ^^^ Change this if you move your application folder
/public/index.php
is the front controller for your webapp; the config path is specified on or about line 16:$pathsPath = FCPATH . '../app/Config/Paths.php'; // ^^^ Change this if you move your application folder
單個(gè)CodeIgniter對(duì)應(yīng)運(yùn)行多個(gè)應(yīng)用?
如果你想要讓多個(gè)不同的應(yīng)用來(lái)共享一次CodeIgniter的安裝文件,只需要將你的應(yīng)用目錄下的所有目錄都移動(dòng)到他們對(duì)應(yīng)的子目錄中即可。
舉例而言,加入你想要?jiǎng)?chuàng)建兩個(gè)應(yīng)用程序,命名為”foo”和”bar”,你可以將你的應(yīng)用目錄排列如下:
/foo
/app
/public
/tests
/writable
/bar
/app
/public
/tests
/writable
/codeigniter
/system
/docs
This would have two apps, “foo” and “bar”, both having standard application directories
and a public
folder, and sharing a common codeigniter framework.
The index.php
inside each application would refer to its own configuration,
../app/Config/Paths.php
, and the $systemDirectory
variable inside each
of those would be set to refer to the shared common “system” folder.
If either of the applications had a command-line component, then you would also
modify spark
inside each application’s project folder, as directed above.