Using ZF2 components without entire MVC process

a 夏天 提交于 2019-12-11 04:34:31

问题


How feasible is it to use the Zend Framework 2 components without using the MVC process? For example I love the forms / validation and ACL elements but am not sure if that is actually possible without the whole MVC system?

As a framework ZF2 is very slow (although I think its a very good system) so would like to encourage its use without the whole package. Thanks.


回答1:


Yes. Zend Form component has a separate repository and it can be used in any application as a component with help of composer. (I'm assuming that you're using composer and your application also uses composer's autoloader) It requires only InputFilter and Stdlib components.

You can try easily. Open your command line:

$ cd /path/to/an-empty-folder

Create a composer.json file with the content below

{
    "name": "Form Demo App",
    "require": {
        "php": ">=5.4",
        "zendframework/zend-form": "2.3.*@dev"
    }
}

and after type

$ composer update

Following dependencies will be installed automatically into the vendor directory and composer.lock will be created :

Loading composer repositories with package information
Installing dependencies (including require-dev)
  - Installing zendframework/zend-stdlib (2.3.3)
    Downloading: 100%         

  - Installing zendframework/zend-validator (2.3.3)
    Downloading: 100%         

  - Installing zendframework/zend-filter (2.3.3)
    Downloading: 100%         

  - Installing zendframework/zend-inputfilter (2.3.3)
    Downloading: 100%         

  - Installing zendframework/zend-form (2.3.3)
    Downloading: 100% 

From performance viewpoint, ZF2 is not very slow. You just need to do couple of things on production environment to run your application much more more performant.



来源:https://stackoverflow.com/questions/26947889/using-zf2-components-without-entire-mvc-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!