ok yesterday i open a thread about when to use mvc,
today im about to learn how does the MVC frameworks works, ive open some framework like CI, CAKE, etc
1.on the .htacsess i found this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/?url=$1 [QSA,L]
</IfModule>
ok so when we type http://localhost/mymvc/something1/something2/something3/somethingetc
we got an $_GET['url'] = string 'something1/something2/something3/somethingetc' (length=45)
2.so i sugest the something1 will be the class, something2 must be the function and something3 im not quite sure, how does exectly framework loads the class ?, functions ?
<?php
class Blog extends Controller {
function index()
{
echo 'Hello World!';
}
function stack()
{
echo 'Hello Stack!';
}
}
?>
3.ok so , i found that every framework first loads the config files, then loads a front-controller this is a front-controller ( on ci ) looks, i assume that they do like this ?
- extends the class ?
- they get the name of the class ? then require_once controller.nameclass.php
- then they somehow search for functions ? ( how do they do that ? )
- next they look for the default function ( function index ) then loads it ?
- if there is a client call the url /Blog/stack it loads just the Stack function, i dont >know how that work either .
- if we put $this->loadview('something') so i assume that they call the function loadview ( that is inside the Controller class and require them by the name, like require_once something.php
maybe there is a part two of this :|,
Thanks a lot.
Adam Ramadhan