1

Modules/およびModules/Application /src内にzf2Applicationフォルダーがあるのはなぜですか?つまり...構造体Modules/Application / src / controllerなどではないのですか?

4

2 に答える 2

2

You can find details of the new zf2 structure http://akrabat.com/zend-framework-2/modules-in-zf2/

As we're using PHP 5.3, we expect that the classes within the src folder will be namespaced. By default, a module's main name is assumed to be its main namespace, Simple in this case. In order to make autoloading simpler and to follow the PSR-0 convention, we create the Simple namespace folder within src. This means that the namespace for the class SimpleController is Simple\Controller within the file src/Simple/Controller/SimpleController.php.

This is obviously one of the more simple modules and it is likely that the src/Simple folder would have other folders such as Model, Form and such like. Also, the view folder would probably have more sub-folders for other controllers.

于 2012-10-18T02:36:42.993 に答える
1

Modules are intended to be single-purpose, reusable containers of code. As such, they will contain everything they need to accomplish that task -- which may (or may not!) include controllers, models, public assets, configuration, view templates, and more.

In order to keep the various pieces semantically grouped, each has its own subfolder in the module. Source PHP code goes in "src", and the code in that directory should follow PSR-0 naming conventions - and thus you'll see the module namespace repeated there. Configuration goes in "config", view templates in "view", public assets in "public", and so on.

That said, you're free to organize your modules however you want, so long as its Module class is discoverable, and it can indicate how to autoload classes and provide configuration to the MVC. The structure you see in the ZendSkeletonApplication and ZendSkeletonModule, however, is recommended as it's the result of a lot of brainstorming within the community, and provides clean semantics for each type of file provided.

于 2012-10-19T03:36:34.663 に答える