Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Directory Structure, multiple sites
 
t.uk
Jr. Member
 
Total Posts:  4
Joined:  2007-09-08
 

Hi,

I’m finding difficult to keep track of Zend’s library versions, in our production and staging servers. And also, when having multiple sites, I can’t create symlinks based on the version number of the library.

For example:

lib/
   
Varien/
   
Zend/

In the production server, developers don’t know which version of ZF is installed.  In the staging server, if I have more than 1 Magento site that uses the ZF, no one will ever know where the symbolic link is pointing to. For example:

var/lib/Zend/
    /
ZendFramework-0.0.9
    
/ZendFramework-1.0.0
    
/ZendFramework-1.0.1

Magento1
/
    
lib/
       
Varien/
       
Zend/ (symlink)

Magento2/
    
lib/
       
Varien/
       
Zend/  (symlink)

Magento3/
    
lib/
       
Varien/
       
Zend/  (symlink)

So, developers get confused and they don’t know which version of the ZF library to use. The solution is quite simple, is just a matter of adding the version number of the framework:

var/lib/Zend/
    /
ZendFramework-0.0.9
    
/ZendFramework-1.0.0
    
/ZendFramework-1.0.1

Magento1
/
    
lib/
       
Varien/
       
Zend-0.0.9/ (symlink)

Magento2/
    
lib/
       
Varien/
       
Zend-1.0.0/  (symlink)

Magento3/
    
lib/
       
Varien/
       
Zend-1.0.1/  (symlink)

Magento4/
    
lib/
       
Varien/
       
Zend-1.0.1/  (symlink)

That’s the main reason why, when you download and uncompress the ZF file, you get something like this:

ZendFramework-1.0.1/
    
Zend/
        ...
 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Hi,

There would be a problem with this solution, as the directory name Zend is needed to find the right library files.

I’m not sure about specifics of your environment, but as far as I can see, a simpler solution would be to include latest stable Zend library directory in the include_path. This way you will not have to have multiple copies or symlinks for each Magento copy.

Let me know if you have any concerns about this way.

 
Magento Community Magento Community
Magento Community
Magento Community
 
t.uk
Jr. Member
 
Total Posts:  4
Joined:  2007-09-08
 

Ok, maybe we need to analyze the pros and cons of doing it that way.

This is your solution:

var/lib/Zend/
    /
ZendFramework-0.0.9
        
/Zend
    
/ZendFramework-1.0.0
        
/Zend
    
/ZendFramework-1.0.1
        
/Zend

Magento1
/
    
lib/
       
Varien/

Magento2/
    
lib/
       
Varien/

File: Magento1/app/Manage.php

ini_set('include_path'ini_get('include_path').PS.BP.'/lib'.PS.BP.'/app/code/core'.PS.'/var/lib/Zend/ZendFramework-0.0.9/Zend');

File: Magento2/app/Manage.php

ini_set('include_path'ini_get('include_path').PS.BP.'/lib'.PS.BP.'/app/code/core'.PS.'/var/lib/Zend/ZendFramework-1.0.0/Zend');

Ok, the symlinks are gone. Now we have a new problem. The developers working on the Magento2 website don’t have access to the Zend framework. They only have access to the /home/sites/Magento2 directory. Only root and Core developers can access the ZF directory. So, Magento2 developers have no way of viewing the core components of the system.

Maybe a normal user will not face this problem, but maybe a Web development agency will.

Here is a good example of an App coexisting with the Zend Framework: Trex. Figure 1.3 - Directory Structure.

My solutions, the same solution provided in Trex:

var/lib/Zend/
    /
ZendFramework-0.0.9
        
/Zend
    
/ZendFramework-1.0.0
        
/Zend
    
/ZendFramework-1.0.1
        
/Zend

Magento1
/
    
lib/
       
Varien/
       
Zend-0.0.9/ (symlink to ZendFramework-0.0.9)
           /
Zend

Magento2
/
    
lib/
       
Varien/
       
Zend-1.0.0/  (symlink)
           /
Zend

File: Magento1/app/Manage.php

ini_set('include_path'ini_get('include_path').PS.BP.'/lib'.PS.BP.'/app/code/core'.PS..BP.'/lib/Zend-0.0.9/Zend');

File: Magento2/app/Manage.php

ini_set('include_path'ini_get('include_path').PS.BP.'/lib'.PS.BP.'/app/code/core'.PS..BP.'/lib/Zend-1.0.0/Zend');
 
Magento Community Magento Community
Magento Community
Magento Community
 
t.uk
Jr. Member
 
Total Posts:  4
Joined:  2007-09-08
 

So, my suggestion is to add the version number of the ZF and an extra path (’/lib/Zend-1.0.1/Zend’) to the inlcude_path directive.

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Just small note for your solution, do not need to include ‘Zend’ folder itself in the include_path, as it’s a part of class name and is used in autoload, only the parent folder is needed.

There are countless ways of doing this and if you need to have different versions of Zend Framework with different instances of Magento, then it’s definitely a good solution.

 
Magento Community Magento Community
Magento Community
Magento Community
 
t.uk
Jr. Member
 
Total Posts:  4
Joined:  2007-09-08
 

do not need to include ‘Zend’ folder itself in the include_path

Yes, my mistake, sorry about that smile

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top