views:

104

answers:

4

I got two projects running, both written in PHP. Now I want to merge these two projects. The first project is a CMS and on a specific page i will display the contents of the other project / application. I don't want the first project to know about, or get access to, the variables and functions in the other and vice versa. So i just want the CMS, the first project, to receive the contents of output of the other project.

I don't want to make another http-request – using get_file_contents or cURL because of load-time. I find passthru() and system() hard to get working, but if that is a possibility, please teach me the way.

I also need to pass some variables from the first project to the other on execution, controller_id and model_id.

Thanks in advance!

EDIT: Iframes and load via javascript is not an option in consideration of accessability guidelines.

+2  A: 

You have several options you already discarded:

  • server side integration at code level (include, etc...)
  • server side integration via curl

You should therefore probably rely on client-side integration:

  • load content via AJAX (best option for me): see Jquery load function, for example. You can pass any parameters, and data, and everything should work
  • load content via iframes
Palantir
it has to be server-side integration.
Fossli
A: 

maybe you could use an iFrame and pass some stuff via the query string... allthough that's another request on load...

Nicky De Maeyer
A: 

What version of PHP are you running? You could always port the portion of the app that will, for all intents and purposes, be considered the "child" to a seperate namespace, effectively cutting it off from all the rest of the app and vice-versa.

Check out the manual entry on Defining Namespaces to see if it's for you

Dereleased
interesting... that covers classes, functions and constants.. that's pretty close!
Fossli
i might go all the way down to php 4 because this is supposed to be highly flexible and mobile.
Fossli
A: 

Use ob_start() to start output buffering. Then you may use ob_get_contents() to get the contents of the output buffer. And clean it afterwards with ob_end_clean(). That way you can intercept one applications output without changing it. But there may be some side effects, which you have to handle.

Your second question about passing some variables cannot be answered in general. Its dependent on your applications' architecture.

Christian Strempfer
yes. i'm familiar with ob_functions... it's handy, but ain't contributing to interference between two projects considering variable-names and functions...
Fossli