phpzend-frameworkmodulecontent-management-systemzend-application

join zend applications on request


How could I join 2 or more zend applications inside another one?
In other words, let's assume that I have this structure:

    /core
        /application
        /public
        ...
    /app1
        /application
        /public
        ...
    /app2
        /application
        /public
        ...

When a access http://some_url.com/core, I want o show the core application but, when I access http://some_url.com/app1, I want to show the core + app1 application.
Basically, it should show the same thing of http://some_url.com/core but with extra links/actions that exists on app1 application.

The same thing should occur with http://some_url.com/app2 (core + app2).

I thought I could create a different index.php for applications app1 and app2 in order to load the "core" application but, my problem is that I don't know how could I access a controller/action of app1 or app2 if I do that, using for example,
http://some_url.com/app1/controller_A/action_B

I'm using Zend Framework 1.11.

EDIT

I saw somewhere a function named addControllerPath. Can anyone tell me if it would work for what I want?


Solution

  • You can get the server uri, and choose your application in index.php

    // Define path to application directory
    $uri = $_SERVER["REQUEST_URI"];
    if (strpos($uri, 'core') == 1) {
        defined('APPLICATION_PATH')
            || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../core'));
    }
    elseif (strpos($uri, 'app1') == 1) {
        defined('APPLICATION_PATH')
            || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../app1'));
    }
    elseif (strpos($uri, 'app2') == 1) {
        defined('APPLICATION_PATH')
            || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../app2'));
    }
    else {
        defined('APPLICATION_PATH')
            || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../default'));
    }
    

    instead the Zend default

    // Define path to application directory
    defined('APPLICATION_PATH')
        || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));