HMVC / Package support to build a modular application
- remo
- Member | 2
I've been looking at different frameworks for quite some time for a big project I intend to start next year. There are a number of options that might work and nette is currently on that list as it support most things I'm looking for (DI, Composer, Routing, MVC) but there's one thing I couldn't find.
The project we'd like to start on would have to be very modular. To achieve this, we'd need to be able to put routes and everything into modules/packages/plugins or whatever you want to call it.
What I'm looking for is a structure like this:
public/
css/
js/
index.php
modules/
module_base/
controllers/
models/
views/
bootstrap.php
module_fun/
controllers/
models/
views/
bootstrap.php
bootstrap.php would be the file which initializes the whole module and might look like this:
<?php
// register routes, services
$container->registerService('myModuleServer', ...);
$router->addRoute(new Route('module_base/human/<id>', 'Human:view'));
// apply database changes
if ($moduleVersionChanged) {
$db = $container->getService('database');
$dbMigrator = $container->getService('database_migrator');
if ($up) {
$dbMigrator->up(...);
}
if ($down) {
$dbMigrator->down(...);
}
}
It's of course just some ugly pseudo code but I think it show where I'd like to go.
Can anyone point me in the right direction? Thanks a lot!
- Filip Procházka
- Moderator | 4668
Yes, Nette has exactly this, but much better :) The concept is called CompilerExtension, you just extend the class and modify everything you want. It's similiar to Symfony's bundles and compiler passes.
Nette itself is configured by one and many more examples can be found here
The examples should give you an idea how this works :)
Last edited by Filip Procházka (2013-10-12 13:43)