views:

29

answers:

2

I've decided that rather than have a copy of the Zend Framework in each application's directory, I'd like to keep it on one location on the server, with the one copy used by all my websites. However, I'd like my app's custom classes to still be within the application folder. So a folder structure a bit like this:

webroot
 |...library
 |     |......Zend
 |
 |...app1
 |     |.....Library
 |              |.......App1
 |
 |...app2
       |.....Library
                |.......App2

How can I get Zend Loader to automatically find the classes in App1 and App2? (preferably by just changing something in application.ini or bootstrap.php)

A: 

You can create a single library directory, with symlinks to the actual live shared code:

webroot/library/Zend -> /path/to/Zend/library/Zend
webroot/library/App1 -> /path/to/App1/library/App1
webroot/library/App2 -> /path/to/App2/library/App2

Then, you only need webroot/library in your path.

To handle version updates, you can simply change the symlink to point to a new install:

webroot/library/Zend -> /path/to/Zend-test/library/Zend
Alex Howansky
I don't really know anything about symlinks, but even if this would work I'm really looking for a solution where creating a new site would be very self-contained: creation of a folder with files in it which are able to rely on Zend being available on the server. Maybe I could do your idea the other way around though: a symlink in App1 pointing to Zend?
wheresrhys
A: 

The Zend Loader will use your php include_path to find files to load.

Simply add webroot/library to your include_path (which you can either do in php.ini or in your bootstrap) and the autoloader should be able to find the framework.

If you are keen to have a shared version of Zend you may as well just use pear (http://pear.zfcampus.org/) to install it and then as long as you have your include_path set to look in your pear dir ( /usr/share/php on my machine ) then you are good to go.

I would advise only to do this for dev machines though, as others have said it's a good idea to be able to control the versions of zend for each app when in production.

Matt Wheeler