ilhan
ilhan

Reputation: 8985

Modules in Zend Framework 2 (ZF2)

Let's say that I'm building a social networking web site. Should I put the whole web site under SocialNetworking module should almost each page have its own module like ProfileModule, MessagingModule, and GalleryModule?

Or it is somethink differen like AvatarModule, UserToUserConnectionModule like FriendshipModule, PrivacyModule?

Upvotes: 3

Views: 296

Answers (2)

Sam
Sam

Reputation: 16455

Just to add something to the good answer of @Ocramius, the examples you've given can ALL be modules.

You can have a "BlogModule". This module would handle BlogPosts. Then you could have an additional "CategoriesModule" that adds the option to give each BlogPost a Category. Then you could write another Module "MediaModule" that adds the functionality to attach Media to your BlogPosts

Upvotes: 3

Ocramius
Ocramius

Reputation: 25431

Modules are not containers of different "pages" of a website.

A module can literally be anything, but in most cases it provides "features" (services, listeners, events, classes, generally logic) for your application.

Don't separate modules thinking at them as separate URLs in your web application: instead, think of them about containers of reusable code.

As a rule of thumb, a Zend Framework 2 Module can be separated from the other functionality on your application if it provides logic that you may want to reuse in another project.

As you can see, it's all about producing reusable and decoupled portions of your application.

Upvotes: 6

Related Questions