How easy is it to extend / modify Zend Framework?

后端 未结 6 703
Happy的楠姐
Happy的楠姐 2021-01-06 17:30

I\'ve recently begun building version 2 of my year-old custom MVC framework. It\'s worked great for me on a number of projects, but I definitely see room for improvement. It

相关标签:
6条回答
  • 2021-01-06 18:05

    I have developed my own framework by extending ZF. And I can tell you that it can be easily done. You can use what you want, and replace what you dont want quite easily. Full ZF follows OOP to the core. They use best practices everywhere. I have learned a lot by observing its code.

    Personally I think ZF is the best php framework I have ever seen.

    0 讨论(0)
  • 2021-01-06 18:05

    It's not perfect - There has been a tendency to use static members and concrete class dependencies in ZF - but some of these have been ironed out in later versions of the framework. I'd say that compared with other similar frameworks, ZF is doing well. In fact the loose coupling is probably the biggest selling point of the framework.

    0 讨论(0)
  • 2021-01-06 18:06

    Among the popular PHP frameworks ZF is surely the one which is most readily extended, especially because of the loose coupling.

    Thanks for the clarifications.

    What you describe is exactly what ZF is good at but I'd say it is also exactly what OOP is good at so I would regard an OO framework that doesn't support this a case for the rubbish bin.

    Anyways. With ZF it's normally done in a way that you keep your own library in a parallel structure to the ZF folder structure. You can use the ZF autoloader and register your library folder with the autoloader by adding it to the namespace. Example:

    //this will be the only require needed for your whole application
    require_once 'Zend/Loader/Autoloader.php';
    $loader = Zend_Loader_Autoloader::getInstance();
    $loader->registerNamespace('Mylibrary_');
    

    In Mylibrary you should then follow ZF naming conventions. Say you want to extend the Zend_Db_Table_Abstract Class. This class is located logically under Zend/Db/Table/Abstract.php. Your library should now replicate that structure: Mylibrary/Db/Table/Abstract.php. And you would name your class in that file:

    class Myproject_Db_Table_Abstract extends Zend_Db_Table_Abstract
    {
        /*
        now you're ready to extend and override as much as you like.
        and as a bonus you'll not even hav to include your library files 
        since your library is registered with the loader
        */
    }
    

    Did you have anything else in mind when asking this question?

    0 讨论(0)
  • 2021-01-06 18:11

    The main point is that you can easily code to interface. Are you not happy with Zend_Acl_Resource implementation? Make your own resource class implementing Zend_Acl_Resource_Interface :)

    0 讨论(0)
  • 2021-01-06 18:17

    it is nearly no problem to extend the Zend Framework.

    It is an common practice to setup some kind of "myExtenions" wich are co existing with the Zend Framework Library. As example you can take a look on :

    Zym Zend Framework Extension

    0 讨论(0)
  • 2021-01-06 18:27

    Personally Zend FW is my favorite. It kicks ass. Period. That said though, you have to be a coder at heart to be able to appreciate it. It can get quite abstract.

    To answer your question; Zend FW is very extendable, everything - really everything - can be extended. Class naming convention is; class Zend_This_IsAn_Example is found in /library/Zend/This/IsAn/Example.php which you would extend as Whatever_This_IsAn_Example which you would put in /library/Whatever/This/IsAn/Example.php It also has autoloading that you can enable, so you won't have to require_once classfiles anymore.

    mvc structure;

    /application /application/controllers /application/etc /application/models /application/views /library /library/Zend /library/Custom /public

    Check out http://framework.zend.com/manual/en/introduction.html and http://framework.zend.com/docs/quickstart

    0 讨论(0)
提交回复
热议问题