CakePHP多个应用程序的共享核心 [英] CakePHP Shared core for multiple apps

查看:106
本文介绍了CakePHP多个应用程序的共享核心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的本地设置我有一个不同的CakePHP网站的负载。我使用Mac,所以文件夹结构是像〜/ Users / cameron / Sites / sample-website ,然后在每个这些网站,我会有典型的蛋糕文件夹和应用程序文件夹。

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.

我想做的只是一个核心蛋糕文件夹,然后所有的网站拉从一个蛋糕核心,所以我不有相同的东西几次。我一直在网上阅读一些教程: http://rickguyer.com/cakephp- one-core-many-apps /

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 / ,然后我的网站在这里:〜/ Users / cameron / Sites / sample-site / 文件夹和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.

现在我已经编辑了webroot中的index.php文件像教程BUT只改变了一行,不像他那样将我的文件移到App文件夹的OUTSIDE外面。所以唯一喜欢我改变的是如下:

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');
}


$ b $ p

据我所知,正确地查找两个目录,文件夹叫 cake-1.3 但是它只是给出一个错误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 如果我在地址栏中粘贴它加载蛋糕文件夹,所以它绝对是正确的文件夹结构JUST它不喜欢看主程序外面的蛋糕?

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;
}


推荐答案

与:

define('CAKE_CORE_INCLUDE_PATH', DS.'Users'.DS.'cameron'.DS.'Sites'.DS.'cake-1.3');

只需确保用户位于root。换句话说,当你去终端,你可以通过输入以下内容进入这个目录: 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上。如果是,您的链接是正确的。大多数时候,我发现是你做了一个应用程序目录的副本粘贴,它没有得到.htaccess文件。我会先检查那些。

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:


  1. 确保主机指向
    正确的目录
    / Users / cameron / Sites / sample-site /

  2. 验证mod_rewrite实际上是否有效。
  3. 确认您已经复制了
    / Users / cameron / bin目录下的 .htaccess
    文件, Sites / sample-site /


    / Users / cameron / Sites / sample-site / webroot
    目录。

  4. 确认
    /Users/cameron/Sites/cake-1.3 /
    目录中有一个名为
    的目录,其中包含核心。

  1. Make sure the host is pointing to the correct directory (/Users/cameron/Sites/sample-site/)
  2. Verify mod_rewrite is in fact on.
  3. Verify you have copied the .htaccess file in both the /Users/cameron/Sites/sample-site/ and the /Users/cameron/Sites/sample-site/webroot directories.
  4. Confirm that the /Users/cameron/Sites/cake-1.3/ directory has a directory called cake in it that contains the core.

一旦确认所有这些,好的金子!

Once all of this is confirmed, you will be good as gold!

快乐编码!

UPDATE:
当index.php文件寻找蛋糕核心时,它将在您指向的另一个目录的名称为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 。您的目录结构将如下所示:

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+此配置从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

这篇关于CakePHP多个应用程序的共享核心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆