How many Classes and Object in 1 page in php v/s MVC
I am trying to create web-application. And I am using
spl_autoload_register() to call for different layer in my page.
For E.g,
I have :-
/www/model/index.class.php
/www/model/search.class.php
/www/model/sidebar.class.php
/wwww/model/category.class.php
/www/model/article.class.php
and calling them all
with
spl_autoload_register(null, false);
function autoloading($class) {
require_once(dirname(__FILE__)."/model/".$class.".class.php");
}
spl_autoload_register("autoloading");
and than in my "index" page.
<?php
$obj_index = new index(); $title = $obj_index->loadTitle(); $obj_index =
NULL;
$obj_search = new search(); $search = $obj_search->loadSearch();
$obj_search = NULL;
$obj_sidebar = new sidebar(); $sidebar = $obj_sidebar->loadSidebar();
$obj_sidebar = NULL;
$obj_category = new category(); $category = $obj_category->loadCategory();
$obj_category = NULL;
$obj_article = new article(); $article = $obj_article->loadArticle();
$obj_article = NULL;
?>
I want to know, Is this bad practice to use so much of class and object in
1 page, will this make my website-slower as compare to code who uses no
class at all and shows data directly fetching at the moment or using
memcache.
Also, I am just not sure, how can i tell my website to load layout from
theme directory. Currently i am coding layout and design everything inside
[classname].class.php but i want my application should have theme or view
directory where , i can any time use my own layout and css to change
website look. If you can help by providing small snippet of code for theme
or view folder option. i can try by poking my each cell to understand and
use it in my code.
Thanks
enthusiastLeaner
No comments:
Post a Comment