windows下cakephp的設定各工程
http://book.cakephp.org/2.0/zh/installation/advanced-installation.html
?
這個url裡面說的很明白,但是下面的說明是以linux為例子進行說明的,在win裡要稍微注意以下
寫道
CakePHP 核心類庫,位於 /lib/Cake 目錄。
應用程式的代碼,位於 /app 目錄。
應用程式的 webroot,通常位於 /app/webroot 目錄。
有三個常量需要修改: ROOT 、 APP_DIR 和 CAKE_CORE_INCLUDE_PATH。
ROOT 應當設定為包含你的 app 檔案夾的目錄路徑。
APP_DIR 應當設定為 app 目錄的目錄名稱(譯註:即不包含前面的路徑)。
CAKE_CORE_INCLUDE_PATH 應當設定為 CakePHP 類庫目錄的路徑。
?
譬如?
寫道
if (!defined('ROOT')) {
define('ROOT', dirname(dirname(dirname(__FILE__))));
}
?
意味著root的路徑是此檔案的父 父 父 檔案夾
?
實際情況下,我的index.php是
C:\USBWebserverv8.5\root\myRootCakephp/index.php
設定的就是,意味著是 父 父資料夾
?
寫道
if (!defined('ROOT')) {
define('ROOT', dirname(dirname(__FILE__)));
}
?
同時,我的app和cake放在了
C:\USBWebserverv8.5\root\cakephp\app
C:\USBWebserverv8.5\root\cakephp\lib
?
寫道
if (!defined('APP_DIR')) {
define('APP_DIR', DS . 'cakephp' . DS . 'app' );
}
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS .'cakephp'. DS . 'lib');
?
app和lib在同樣的路徑下,為什麼設定的時候,一個加了root,一個沒加呢?
?
在app上加了root後,會出現
Warning: include(C:\USBWebserverv8.5\root\C:\USBWebserverv8.5\root\cakephp\app\Config\core.php) [function.include]: failed to open stream: Invalid argument inC:\USBWebserverv8.5\root\cakephp\lib\Cake\Core\Configure.php?on line?72
?
裡面有2個c盤符,沒辦法,只能去掉
?
而如果lib上沒加root的話
?
Warning: include(\cakephp\lib\Cake\bootstrap.php) [function.include]: failed to open stream: No such file or directory in?C:\USBWebserverv8.5\root\myRootCakephp\index.php?on line?97
?
會直接認成類似於linux的路徑。win自然認不出來
?
所以說,調來調去的結果,只能是上面這個樣子,當然,這也說明,root,lib,app,是可以完全分開的,完全符合cakephp的說明。linux上可能會比較容易點。
?
?