I've read several articles about HMVC, in PHP and other languages, and in all of them the implementation of this pattern was about having a "Master-Controller" requesting the Response Body of one or more resources, internal or external, using cURL or Stream Contexts, in order to build its own, directly through a Response object or through a custom View Engine, assigning template variables with the HTML obtained.
However, all of these articles, clung so much to the technical concept, that most of times they did not mention all pertinent points. So the conclusion I came with was the basic concept of HMVC is, generally speaking, an MVC inside MVCs, working seamlessly both hierarchical or isolatedly, always in the same way.
But how exactly would happen the HTML componentizing of this "Master-Controller" if, in order of each subsystem to work in the same way by all means it would need eventual scripts, stylesheets or even extra markup?
With an example it gets easier to understand:
Considering an Application developed with Bootstrap 3 made of N components, all of them also developed with the same framework (so they work isolatedly the exact same way it would when part of main Application), with an HMVC figuratively created with 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()
)
);
As a matter of clarification in this fragment Request::send() would return the HTML
Would result in something 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>
Which, in this example, is "just" wrong, after all, in a real Application we could have script conflicts or CSS rules messing any HTML coming after the section designed to the component (like a footer or another subsequent component) and so on...
That said, how the HTML componentizing should happen in a HMVC?
The smallest idea that I come across would be this "Master-Controller" to parse the HTML received of each component and get only what it really need from it, like everything inside a specific wrapping DIV inside the <body></body>
.
But I haven't seen anything even remotely close to this in anything I've searched for.