CakePHP Shared core for multiple apps

前端 未结 5 1885
我寻月下人不归
我寻月下人不归 2020-12-10 08:45

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 a

相关标签:
5条回答
  • 2020-12-10 09:19

    If you have access to your php.ini, you can add the path to Cake core there. Doing it this way means you don't have to change webroot/index.php at all. Example in php.ini:

    include_path = ".:/usr/local/lib/php:/home/something/phpinc/cakephp2/lib"
    

    According to the CakePHP 2.x docs, this is the recommended way to share the Cake core (assuming you have access to your php.ini).

    0 讨论(0)
  • 2020-12-10 09:19

    There is no need to edit index.php.

    Just put an alias (or link in UNIX) to your cake folder in each of your sites folder. Works perfectly. Same goes for plugins and vendors folder.

    0 讨论(0)
  • 2020-12-10 09:23

    You can have only one cake core but you must have one app folder (containing MVC) by site.

    0 讨论(0)
  • 2020-12-10 09:37

    You are right on the money with:

    define('CAKE_CORE_INCLUDE_PATH', DS.'Users'.DS.'cameron'.DS.'Sites'.DS.'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

    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. 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!

    Happy Coding!

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

    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+ In CakePHP 3.0+ this configuration is moved out of webroot/index.php to App/Config/paths.php

    0 讨论(0)
  • 2020-12-10 09:37

    Is this a misunderstanding of the folder structure of CakePHP?

    From the docs (CakePHP folder structure):

    • The app folder will be where you work your magic: it’s where your application’s files will be placed.
    • The cake folder is where we’ve worked our magic. Make a personal commitment not to edit files in this folder. We can’t help you if you’ve modified the core.

    So the cake folder shouldn't change between all of your uses, therefore you have 1 copy. You can always change some of the functionality of the core by making your own changes in the app folder i.e. extending.

    0 讨论(0)
提交回复
热议问题