简体   繁体   中英

An approach of shared libraries of plugins for Zend Framework

Searching I noticed that generally in Zend Framework based applications, plugins are inside the library folder. But I'm trying to work in a way that different applications use the same library of plugins.

My intuition tells me that these plugins should be external to the application if another application can use it. What I am wanting to do is a library of plugins for my ZF applications. The structure I am looking for would be something like this:

www/
    zf-app-1/
    zf-app-2/

www-library/
    zf-my-plugins/
        database/
            EnttityManager.php
            DoctrineEntityManager.php

Thus, zf-app-1 and zf-app-2 use the same external plugin to them. I may be wrong, but this approach is more logical to me than zf-app-1 and zf-app-2 possesses a copy each of the same plugin folder in your library. Would you like opinions on this my thought.

But my question is about how to configure applications zf-app-1 and zf-app-2 to use this shared library. I would make it through the application.ini of each.

Thanks!

If you want a shared library outside of your project folder like this:

stuff/projects/zfproject1
stuff/projects/zf2project2
stuff/projects/zf2project3
......
stuff/shared/library <--- shared libraries go in here

Let's assume a shared library called MyLib

stuff/shared/library/MyLib

You will need to

  1. Add the library folder to your include path
  2. Add the library namespace to the autoloader

Your application.ini:

autoloaderNamespaces[] = "MyLib_"
includePaths.library = APPLICATION_PATH "/../../../library"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM