Separation of API related controllers from the main application with sharing common business logic objects. Advice needed

Hello Bakers!

This is my first post here and I need your advice on how to accomplish the following. I’m currently working on a project for which I want to build an API interface. I started sketching it up and discovered that there is a number of ways I can do it in terms of organization of files and routes.

The first one (the one I’ve chosen for now) is very simple. I created a separate directory under src/Controller, called it api and now I’m able to create controllers in it, create a separate AppController and everything looks straightforward and neat. This way allows me to share Models, Components and other pieces of the system with my controllers located in src/Controller/api.

In the future, I have plans to move my API to a separate server because this will be the most loaded part of the system. Here is where my main question comes in.

What is the best way/practice of sharing business logic components between two separate CakePHP applications which use the same DB?

I understand that I can simply copy my Table classes and other required objects from “project A” to “project B”, but this will require additional maintenance and synchronization work and will not keep my code clean.

I would be grateful for advice and tips.