I am building a social network type site similar to Facebook. I am using PHP, javascript, jquery, MySQL, Memcache, and APC. I previously have built social networks with PHP and they were very complex and large applications (user system, forums, blogs, profiles, virtual currency, store for currency, messaging, and lots more features/sections/modules but all done in procedural style coding, I have spent the past year researching PHP object oriented OO and I now have a much better understanding of OO in PHP ( many thanks to Stackoverflow ). Before, I knew nothing at all about classes and objects or how to use or create them.
Ok so back to the question, I am going to build my own framework or better said, "Library" of code for this project and then I can use it in the future if needed. I do not want to use existing framework, I would much rather build my own so I can really learn how eac method and object, etc.. are working.
I am leaning towards using the MVC pattern or something very similar. I will have what I will call Modules. example modules; Users or account, mail/messaging, forums, blogs, etc.... each Module will pretty much be drop in and it will work with my other code. So each module will have it's own folder and be pretty much self contained. "modules/forums/" could have controllers + models + views.... "modules/forums/controllers/" "modules/forums/models/" "modules/forums/views/"
That is my basic IDEA so far, it can and will probably change some when it's all said and done.
I have already created a Routing class that will take in an Array Map of URI to match. Example result if I went to
www.domain.com/forums/viewtopic/id-242342/page-23
Then I I would have an array matched with regex that would give me something like this...
$uri['module'] = 'forums';
$uri['method'] = 'viewtopic';
$uri['id'] = '242342';
$uri['paging'] = '23';
I can then use that array to build or call the appropriate stuff for that page.
I am thinking about using a simple template/view class to include a view file that will have html and PHP mixed but with no real logig besides if/else, foreach, variables, etc
Where my real question or where I am not understanding fully...This MVC type pattern seems to work great for simple pages, for example a blog, I could have MVC to show a blog post or list of blogs, but a more complex page like you would seen in a site like facebook, a blog page, might be more then just blog stuff, it may have advertisment block, friends block, etc and other stuff on a page, is it a bad idea to use MVC and views/templates for a site like that? I notice all the social network sites including facebook, not one of them seems to use this system, they all have seperate pages to build the page, example, mail/messages will be on messages.php instead of everything routed through 1 file.
I hope this question/post makes sense to someone and someone can offer some insight, thanks for your time and any suggestions/tips/advice!
I would use an existing framework, however if you're insistent on creating your own, have at look at this article about how to write your own PHP MVC framework. It's very informative and shows you the inners of how to overcome some of the challenges assosiated with such a task.
As for the power and capability of MVC as a design pattern for complex webpages, Stackoverflow uses ASP.NET MVC 3 as it's WebFramework (ref). Nuff said.