Yii Framework Forum: HMVC for Yii2.0 - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

HMVC for Yii2.0

#21 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,780
  • Joined: 17-January 09
  • Location:Russia

Posted 21 June 2013 - 04:47 AM

With the latest changes to Yii2 codebase I think HMVC is now possible. I still don't think we'll advertise it in the guide because there are better tools for the job.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#22 User is offline   rAWTAZ 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 102
  • Joined: 08-January 10

Posted 26 June 2013 - 08:34 AM

Interesting. Would you mind elaborating just a little on which changes you are referring to?
0

#23 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,780
  • Joined: 17-January 09
  • Location:Russia

Posted 26 June 2013 - 03:00 PM

Recent testing-related stuff: wrappers around request and response.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#24 User is offline   phazei 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 64
  • Joined: 20-July 09

Posted 10 September 2013 - 08:45 PM

I'd just like to add an example use case to this thread for internal requests using HMVC that I don't believe could be resolved using any other method including modules.

I work for a web and mobile development company. I'm their primary PHP 'engineer'. About 80% of what I build are RESTful API's to interface with the Android and iOS apps we build. Basically, we create API's for nearly every action taken on a model, then use those for both the mobile apps and any web interfaces we use. Most of the web stuff is AJAX so it works pretty well.

There are often times though we need to internally call the API internally.

For example if there are multiple user types, we would call the create user method for say "publisher" and that would internally call the API for basic users. This way we can still call the basic user independently, but can also reuse all that logic for publisher users that might need other tables and data setup as well.

A second example is multiple requests bundled into one. With mobile apps speed is one of the highest concerns. If we need to do one API request for brands, and one for zip codes, and yet another for say venues, 3 separate requests can be expensive and timely. Instead we can have a API request handler, where an array with say:
Array(
 	'request1' => (
   			uri => "api/brands",
   			method => "post"
   			data => array( ... )
          ),
 	'request2' => (
   			uri => "api/venues",
   			method => "get"
   			data => array()
          ),
    request3 => ( ... etc ... ),
)


Which can handle extra requests.

I can see how there's not an incredible need for HMVC for view components when there are modules, but those don't provide any solution for an API driven site.


I posted a little more detail about this type of site design here.
0

#25 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,780
  • Joined: 17-January 09
  • Location:Russia

Posted 11 September 2013 - 04:44 AM

When I've designed API at Stay.com we had the same concerns and it was solved w/o HMVC. I've just created another layer that incapsulated all the logic and both used in API endpoints, batch endpoint and the application itself.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users