問題描述
在我的本地設(shè)置中,我有很多不同的 CakePHP 網(wǎng)站.我使用的是 Mac,因此文件夾結(jié)構(gòu)類似于 ~/Users/cameron/Sites/sample-website
,然后在每個(gè)網(wǎng)站中,我將擁有典型的 Cake 文件夾和 App 文件夾.
On my local setup I have a load of different CakePHP websites. I'm using a Mac so the folder structure is something like ~/Users/cameron/Sites/sample-website
and then within each of these websites I will have the typical Cake folder and App folder.
我想做的是只有一個(gè)核心蛋糕文件夾,然后讓所有網(wǎng)站都從那個(gè)蛋糕核心中提取出來,這樣我就不會(huì)多次使用相同的東西.我一直在網(wǎng)上閱讀一些教程:http://rickguyer.com/cakephp-一核多應(yīng)用/
What I would like to do is have just a core cake folder and then have ALL the sites pull from that one cake core so I don't have the same stuff several times over. I have been reading some tutorials on the web: http://rickguyer.com/cakephp-one-core-many-apps/
所以我的蛋糕文件夾在這里:~/Users/cameron/Sites/cake-1.3/
然后我的網(wǎng)站在這里:~/Users/cameron/Sites/sample-site/
在這個(gè)文件夾中,我有常用的 app 文件夾和 htaccess 來告訴它在哪里可以找到 webroot 等.
So I have my cake folder here: ~/Users/cameron/Sites/cake-1.3/
and then my site here: ~/Users/cameron/Sites/sample-site/
and in this folder I have the usual app folder and htaccess to tell it where to find webroot etc.
現(xiàn)在我像教程一樣編輯了 webroot 中的 index.php 文件,但只更改了一行,因?yàn)槲覜]有像他那樣將我的文件移到 App 文件夾之外.所以我唯一改變的像如下:
Now I have edited the index.php file inside webroot like the tutorial BUT have only changed one line because I haven't moved my files OUTSIDE of the App folder like he does. So the only like I have changed is as follows:
if (!defined('CAKE_CORE_INCLUDE_PATH'))
{
define('CAKE_CORE_INCLUDE_PATH', '..'.DS.'..'.DS.'cake-1.3');
}
據(jù)我所知,正確查找兩個(gè)目錄并找到一個(gè)名為 cake-1.3
的文件夾,但它只是給出了錯(cuò)誤 500?
As far as I can tell that is correctly looking two directories up and finding a folder called cake-1.3
however it just gives a error 500?
任何想法是什么問題?謝謝
Any ideas what the problem is? Thanks
即使這樣做也不起作用???如果我回顯:echo CAKE_CORE_INCLUDE_PATH;
給出 /Users/cameron/Sites/cake-1.3
并且如果我將其粘貼到地址欄中,它會(huì)加載蛋糕文件夾,因此它是絕對(duì)是正確的文件夾結(jié)構(gòu),只是它不喜歡在主 url 之外查看蛋糕?
Even doing this doesn't work???
Which If I echo: echo CAKE_CORE_INCLUDE_PATH;
gives /Users/cameron/Sites/cake-1.3
and if I paste that in the address bar it loads up the cake folder so it's definitely the correct folder structure JUST it doesn't like looking at cake outside of the main url?
if (!defined('CAKE_CORE_INCLUDE_PATH'))
{
define('CAKE_CORE_INCLUDE_PATH', DS.'Users'.DS.'cameron'.DS.'Sites'.DS.'cake-1.3'); echo CAKE_CORE_INCLUDE_PATH;
}
推薦答案
你是對(duì)的:
define('CAKE_CORE_INCLUDE_PATH', DS.'Users'.DS.'cameron'.DS.'Sites'.DS.'cake-1.3');
只需確保用戶位于 root 中.換句話說,當(dāng)您進(jìn)入終端時(shí),您可以通過鍵入以下內(nèi)容進(jìn)入該目錄:cd/Users/cameron/Sites/cake-1.3
Just make sure that Users sits in root. In other words, when you go to terminal you can get to this directory by typing: cd /Users/cameron/Sites/cake-1.3
看起來您可能使用的是 MAC.如果是這樣,您的鏈接是正確的.大多數(shù)情況下,我發(fā)現(xiàn)您已經(jīng)完成了應(yīng)用程序目錄的復(fù)制粘貼,但它沒有獲得 .htaccess 文件.我會(huì)先檢查那些.但這里有一份您應(yīng)該驗(yàn)證的綜合清單:
It looks like you may be on a MAC. If so, your linking is correct. Most of the time what I find is you have done a copy paste of the app directory and it does not get the .htaccess files. I would check those first. But here is a comprehensive list of what you should verify:
- 確保主機(jī)指向正確的目錄(
/Users/cameron/Sites/sample-site/
) - 驗(yàn)證 mod_rewrite 是否真的開啟.
- 確認(rèn)您已復(fù)制
.htaccess
在兩個(gè)文件中/Users/cameron/Sites/sample-site/
和/Users/cameron/Sites/sample-site/webroot
目錄. - 確認(rèn)
/Users/cameron/Sites/cake-1.3/
目錄有一個(gè)名為的目錄蛋糕在里面,里面有核心.
- Make sure the host is pointing to
the correct directory
(
/Users/cameron/Sites/sample-site/
) - Verify mod_rewrite is in fact on.
- Verify you have copied the
.htaccess
file in both the/Users/cameron/Sites/sample-site/
and the/Users/cameron/Sites/sample-site/webroot
directories. - Confirm that the
/Users/cameron/Sites/cake-1.3/
directory has a directory called cake in it that contains the core.
一旦這一切都得到確認(rèn),你就會(huì)像金子一樣出色!
Once all of this is confirmed, you will be good as gold!
快樂編碼!
更新:當(dāng) index.php 文件查找 cake core 時(shí),它??會(huì)在您指向的位置中查找另一個(gè)名為 cake 的目錄.所以在你的情況下:
UPDATE: When the index.php file looks for the cake core, it will look for a directory inside the location you are pointing to for another directory called cake. So in your case:
define('CAKE_CORE_INCLUDE_PATH', DS.'Users'.DS.'cameron'.DS.'Sites'.DS.'cake-1.3');
您必須在 /Users/cameron/Sites/cake-1.3
中擁有 cake 目錄.您的目錄結(jié)構(gòu)將如下所示:
You must have the cake directory inside /Users/cameron/Sites/cake-1.3
. Your directory structure will look like:
/Users/cameron/Sites/cake-1.3/cake
/Users/cameron/Sites/cake-1.3/cake/libs
/Users/cameron/Sites/cake-1.3/cake/config
/Users/cameron/Sites/cake-1.3/cake/console
etc.
CakePHP 3.0+在 CakePHP 3.0+ 中,這個(gè)配置從 webroot/index.php 移到 App/Config/paths.php
CakePHP 3.0+ In CakePHP 3.0+ this configuration is moved out of webroot/index.php to App/Config/paths.php
這篇關(guān)于CakePHP 多個(gè)應(yīng)用程序的共享核心的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!