HMVC for Yii2.0
Posted 21 June 2013 - 04:47 AM
Posted 10 September 2013 - 08:45 PM
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.
Posted 11 September 2013 - 04:44 AM