Welcome Guest, Not a member yet? Register   Sign In
Dynamic application defining in 5 lines of code
#1

[eluser]Sbioko[/eluser]
Curious? :-) In this topic I'll explain how you can implement True HMVC using just 5 lines of code. You don't need to use any MY_ classes and additional libraries! So, let's start!

Step 1: Create modules folder and move your application folder into it.

Step 2: Open index.php and find this line:
Code:
$application_folder = 'application';
Where application is the name of your application's folder.

Final step 3: And replace this code to this:
Code:
$application_folder = '../modules/application'; // you must replace application to your default module/controller.

$URL = explode('/', $_SERVER['REQUEST_URI']);
if(isset($URL[1]) && $URL[1] !== '' && is_dir('modules/'.$URL[1])) {
    $application_folder = '../modules/'.$URL[1];
}

That's all! Now you have full HMVC :-) But, there are some known issues with it:
1) You can have only 1 controller per "module" and it must be named same as the module's name. For example: Module Blog can have only 1 Blog.php controller.
2) Security. I think, that here is possible to do PHP-inj. This is just my opinion. You can disagree with me.

So, what are you think about it? :-)


Messages In This Thread
Dynamic application defining in 5 lines of code - by El Forum - 02-23-2010, 06:28 AM
Dynamic application defining in 5 lines of code - by El Forum - 02-23-2010, 09:18 AM
Dynamic application defining in 5 lines of code - by El Forum - 02-23-2010, 09:18 AM
Dynamic application defining in 5 lines of code - by El Forum - 02-23-2010, 09:28 AM
Dynamic application defining in 5 lines of code - by El Forum - 02-23-2010, 10:55 AM
Dynamic application defining in 5 lines of code - by El Forum - 02-23-2010, 11:26 AM
Dynamic application defining in 5 lines of code - by El Forum - 02-23-2010, 11:33 AM
Dynamic application defining in 5 lines of code - by El Forum - 02-23-2010, 11:47 AM
Dynamic application defining in 5 lines of code - by El Forum - 02-23-2010, 07:17 PM
Dynamic application defining in 5 lines of code - by El Forum - 02-24-2010, 01:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB