Closed panique closed 9 years ago
Interesting stuff this project learning so much.
I have been working on the original PHP-MVC project and plan to commit it but have added theme/cache support for twig which could be useful:
public function render($view, $data_array = array(), $cache = false) {
if ($this->enableTwigCache) {
$cache = true;
}
// load Twig template engine
$twig_loader = new Twig_Loader_Filesystem(SITEFOLDER . 'views');
//Add path to keep theme seperate from views
$twig_loader->addPath(THEMEDIR . $this->theme . '/');
if ($cache) {
// Cached in APP.cache (needs to be writable by webserver)
$twig = new Twig_Environment($twig_loader, array(
'cache' => APP . 'cache',
));
} else {
$twig = new Twig_Environment($twig_loader);
}
//Pass Defaults values to template.
$defaults = array();
$defaults['PARENT'] = (string) PARENT;
echo $twig->render($view . '.twig', array_merge($data_array, $defaults));
}
2) Moved the Models/Views/Controller into a seperate folder so I can move them about from server to server easily.
3) Used Namespaces/PSR-4 (was orignally just using composer's class loader) to preload any classes I would need through out the project.
@djsmithme Sounds good, can you show some code ?
https://github.com/djsmithme/php-mvc-advanced/tree/djs-ideas/djs-ideas
I'll upload it properly when I get a moment.
MINI2 currently consists of 2 simple .php files:
MINI2 is just a quick thing I've built for quick projects (in daily agency work you have setup sometimes 3 applications per week), and using real frameworks is totally overdoze in most cases, so this makes sense.
However, it might be better to a.) move the configs b.) split the model to multiple files, so the user can organize data-handling methods (like classic UserModel extends Model, you know what I mean :) ). c.) move the routes, split the routes to multiple files
What do you think ? Ideas ? Code ? Feature branches ?