This may seem like a silly question if so sorry =]
Ok i have been building a php framework a small one to speed up development. I know there are others such as codeignitor but i want the knowledge of building one from scratch. Anyways I have created a structure best I can through research etc.
I have everything separate like;
application/
/models / My Models such as Database.php
/views < I have a View.php
/controllers < I have a HomeController.php
I set up all the main stuff with the index.php any queries get passed to php and it does what it needs to do like so:
http://localhost/Framework/home/index
This will translate into HomeController->index
So i set my variables n such in the index method and then send it all to the view class to be rendered… works a charm.
My question is this, do I need a different class for each page? like: http://localhost/about/
Maybe this would then point to AboutController->index or is it fine as is like this: HomeController->about
I think the latter is correct or does it even matter?
When merging the
aboutandindexpages to one controller,HomeControllerisn’t a proper name. However, it’s a perfectly valid approach.Controllers usually group types of pages together. For example, you’d have all your login pages (actions) in one controller, all blog actions (create, retrieve, update, delete) in one controller, etc. If your
aboutandhomepages both welcome people to your site, call it something likeWelcomeController.