How to make a multiple app on Cakephp 3.3.9?

I want to a multiple app in one app for CakePHP 3.3.9, my idea is

CakeCore
CakeBase
app_1
app_2
app_3

What I did so far is:

  • Move CakeBase/vendor/cakephp to CakeCore
  • Edit CAKE_CORE_INCLUDE_PATH in my CakeBase/config/path pointing CakeCore/cakephp

And here are my questions:

How i can get work app_1, app_2 and app_3 with the base controller of my CakeBase app or app_1 controller with another controller in app_2?

Why if I delete CakeBase/vendor the application throws error 500, if I have pointing the core to CakeCore?

I hope anyone can help me with this

Typically, CakePHP is quite reliant on composer, and the vendor directory is located within each app. Moving the location of vendor/cakephp to CakeCore is going to break composer and any of the autoload stuff that it might have been set up with.

If you really need to share the same cakephp vendor code between all apps, just set up a softlink of vendor/cakephp from the first app to the other two. But you’re going to tie yourself in knots, having to maintain all three apps at the same time with the same version. Probably just better to let the separate apps have their own version of cakephp, and give yourself the freedom to update the vendor code base for each app at a different time.

That’s the idea because only I need modify the core, to get the change in all the apps, that’s the reason to do the multi app plataform,

ex.
app_1 = www.example.com
app_2 = www.example2.com
app_3 = www.example3.com

and they have a app base, with the login with some bussiness rules and only need change one file…
I do this in cake 2.x but i can’t get the info to do in cake 3.3.x

I would strong advice against that. I think that there are pretty much two cases for multiple applications with the same CakePHP instance:

  1. When you are on a shared hosting with very limited disk space.
  2. When you have a multi-tenant application, where there are many apps, but they are all pretty much the same.

For everything else, I think it’s way better to use dedicated instances of CakePHP. If you want the same changes on multiple projects, it’s easily achievable these days with composer or even with git submodules (which aren’t the most elegant solution either).

Having several different applications on top of the same CakePHP installation will make your future upgrades very difficult, as you’d need to test and fix all those apps at once in order to upgrade CakePHP. If you are also patching CakePHP itself, you are pretty much in the “this is impossible” area. :slight_smile:

2 Likes