8
I have read several articles on HMVC, both in PHP and in other languages, and in all of them the implementation of the standard revolved around having a "Master Controller" which requested the Response Body of one or more internal or external resources via Curl or Stream Contexts, in order to assemble its own, directly into an object responsible for the Response, or through its own View Engine, creating template variables with the obtained HTML(s)).
However, all these articles were very attached to the technical concept and sometimes did not cover all the relevant points. With this the conclusion that I was able to reach was that the basic concept of HMVC is, roughly, Mvcs within Mvcs, which work both hierarchically and separately, always in the same way.
But how exactly would the HTML componentization of this "Master Controller" if, so that each subsystem works the same way in every way any additional scripts, style sheets or even markup would be required?
With an example it becomes easier to understand:
Considering an application whose GUI would be developed with Bootstrap and composed of N components, all also developed with the same framework (to function as the main application alone), with a HMVC figuratively created by the pseudo-code below:
// Make the Requests
$projects = new Request( 'management/projects', 'GET' );
$clients = new Request( 'management/clients', 'GET' );
// Creates the Template Variables with Response Bodies HTML
$this -> view -> assign(
array(
'projects' => $projects -> send(),
'clients' => $clients -> send()
)
);
By way of clarification of that fragment, Request:() would be returning HTML
It would result in an HTML similar to:
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
</head>
<body>
<div class="container-fluid">
<!-- Sidebar -->
<div class="row">
<div class="col-sm-3 col-md-2 sidebar" id="sidebar" role="navigation">
<ul>
<li>Sidebar Item</li>
<li>Sidebar Item</li>
<li>Sidebar Item</li>
</ul>
</div>
</div>
<!-- Main Content -->
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
</head>
<body>
<div class="container-fluid">Component HTML</div>
</body>
</html>
</div>
</div>
</body>
</html>
What in this simple example is "just" incorrect, after all, in a real application we could have script conflict, or CSS rules that make use of the !Important messing with existing HTML afterward of the section designated for the component (a footer, for example) and etc.
Therefore, how should HTML componentization occur in a HMVC?
The least idea I can think of would be for the "Master Controller" to analyze the return HTML and only take what was inside the <body></body>
, but I didn’t see anything remotely similar to that in what I researched.
Kohana has a HMVC model. That link has some considerations about HMVC.
– Papa Charlie
But did you see that at any time it touches on the problem of doubt that I raised? In the article the construction of such Gazouillement only demonstrates the technique of composition, but does not cover how the final HTML would look. A View that it builds with the received data does not specify these Response Bodies already come clean of any unnecessary markings for Main Application or if something else is being done.
– Bruno Augusto
Why HMVC and DON’T SOUND ?
– gmsantos
Maybe because I don’t know much more than just the definition of SOA. u.u'
– Bruno Augusto