My company runs 2 websites, a public facing website for clients, and an employee intranet. The intranet is used as a backend for employees to edit and maintain various parts of the public website. Both are written in PHP. The intranet is years older, and was designed using an inhouse framework. We have recently created a new public website, and because of the opportunity to "start from scratch" with it, we designed it using a PHP framework (Kohana). We knew from the beginning that there would be implementation issues with getting the intranet to interact with the public site, and vice-versa. We are now at that point.

There are a few different ways we have been able to make things work: For direct data manipulation, both use mysql, so the query builder in Kohana can manipulate the same data as the straight mysqli queries of the intranet. But beyond that, when the public site needs to use certain auditing methods written on the intranet framework, or when the intranet needs to send an automatic email written in Kohana, or use any number of other methods and functions, we have

1- Included one framework within the other, to have access to both. Problems with this are:

a. Both rely on object buffering to prepare output, and are constantly starting and ending buffers at odd times.

b. Conflicting class names being autoloaded

c. autoloaders overwriting each other

d. errors designed to be handled in one way are being handled improperly by the other framework's error handler.

e. any number of other incompatibility issues

We have gotten around these on a case by case basis, but it has been a nightmare

2- Using a remote API. We have written webservice methods on each server, and the other framework makes a cURL request of the other server. Problems with this are:

a. The added work of protecting the API and authenticating requests

b. the need to write service methods

c. The overhead of having to make http requests instead of loading files locally

3- Using a local api. Similar to the above, except the framework is included on the same server, and the api methods are written in shell scripts which output data to be read by the calling script via shell_exec. This alleviates the need for authentication, but it seems like an ugly, hacky way of doing things

We don't want to rewrite the intranet using a proper framework. It would take an incredible amount of time that we do not have. Is there a better way to do this, or at least a more "standard" or "conventional" way of dealing with this problem? Or are we stuck hacking away at it like we currently have been?

2 Answers 2


firstly for multiple classes with the same name, I would suggest that you use namespaces to clear out what class in which namespace is supposed to handle it.

most frameworks error handlers can be overwritten to achieve custom error handling , I'm using Yii and at least that is supporting it.

and also you can use the old frameworks working parts and include them in your new framework and reuse your code.


I would suggest expanding on 2. You can secure your endpoints by IP whitelisting.

There is not much overhead involved in making HTTP requests. Worry about other bottlenecks like inefficient SQL and file I/O.

Having two incompatible systems talk to one another requires an agreed upon API. This is a fundamental fact. Sandboxing one inside the other is just going to give you the runaround.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.