views:

465

answers:

2

Zend Framework project structure presumes you run only one application per server, like localhost/guessbook, where controllers and stuff are located one folder above that level.

How can I have a few different ZF-based projects in my localhost so that to address them like I do with regular php script apps - with localhost/app1, localhost/app2?

Ideally, I want to do without DocumentRoot, I want to switch between apps instantly using browser.

+1  A: 

I think that you are wrong on this one. You can have multiple zend framework application on the same hostname. I.e. i've been using multiple magento's installation on my server in order to try out things. Zend doesn't have fixed file structure as far as i know (one of the reason of my choice of framework)

You can place even place Zend Library outside the webroot folder and call it with something like this:

$lib = realpath(dirname(basename(__FILE__)) . '/../../../lib');
set_include_path(get_include_path() . PATH_SEPARATOR . $lib);


$rootDir = dirname(dirname(__FILE__));
        define('ROOT_DIR', $rootDir);

        set_include_path(get_include_path()
            . PATH_SEPARATOR . ROOT_DIR . '/library/'
            . PATH_SEPARATOR . ROOT_DIR . '/app/models/'
        );

        include 'Zend/Loader.php';
        spl_autoload_register(array('Zend_Loader', 'autoload'));

        // Load configuration
        Zend_Registry::set('configSection', $configSection);
        $config = new Zend_Config(new Zend_Config_Ini(ROOT_DIR.'/application/config.ini', $configSection));
        Zend_Registry::set('config', $config);
Alekc
+2  A: 

I don't quiet understand what's the problem? Perhaps you're referring at typical rewrite rules that send to /index.php? Well, you can change that rewriting rules from

RewriteRule ^.*$ /index.php [NC,L]

to

RewriteRule ^/app1/.*$ /app1/index.php [NC,L]
RewriteRule ^/app2/.*$ /app2/index.php [NC,L]

In bootstrap.php you define all the include path, so you can have Zend Framework libraries shared.

vartec
Even simpler than that, rather than having one large set of rewrite rules in the main directory, just place the 'standard' one in each of the subdirectories.
Sean McSomething