管理多個應用?
默認情況下,我們假設你只是用CodeIgniter來管理一個應用,并將該應用在 application 目錄下進行構建。 然而也存在這樣的可能性:多個應用共享一個CodeIgniter的安裝目錄,甚至開發者會將 application目錄進行重命名或移動位置。
重命名或遷移應用程序目錄?
如果你想重命名你的應用文件夾或者移動
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
單個CodeIgniter對應運行多個應用?
如果你想要讓多個不同的應用來共享一次CodeIgniter的安裝文件,只需要將你的應用目錄下的所有目錄都移動到他們對應的子目錄中即可。
舉例而言,加入你想要創建兩個應用程序,命名為”foo”和”bar”,你可以將你的應用目錄排列如下:
/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.