drcphd Posted September 17, 2007 Share Posted September 17, 2007 (I hope I've not posted this in the wrong forum: I'm actually looking for input on my approach, not the coding directly). I want to write my own CMS (with basic features I always need) for my future projects. I've tried two times before but had to stop due to lack of planning. Lately I've been reading about MVC (Model-View-Controller) designs and registry patterns. I've come up with a solution that I think might work. I have a registry class to store all objects and a module handler which fetches output from the different modules (like a router). But in this example you can load several modules simultaneously. That means you can assign module-output anywhere on the page (as main content, block content, etc). The 'main module' (requested by user, think $_GET['mod']) will always be responsible for the main content (the body of the page). But every other module can also be loaded and create output for other parts of the page (like a poll in a block). My approach is best explained by looking at a simplified framework I wrote. http://pastebin.org/2655 - View code Comments? Is this a stupid idea? Also, if anyone has something to say about the object oriented programming in this example, that would be great. I'm still learning, and it would be nice to know if I've grasped the basics, e.g. how the registry object should be treated. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/69700-small-framework-for-an-mvc-registry-pattern/ Share on other sites More sharing options...
deadimp Posted September 18, 2007 Share Posted September 18, 2007 There aren't really stupid ideas when you're learning something new... Unless what you're doing is counter-productive (which kind of negates what I just said). I you feel you have a sturdy structure in mind, or that you could develop one over time, just go for it. It's a learning process. If it fails, move on to something else. If you aren't sure of or don't believe in a project you start, don't plan on killing yourself over it. Be flexible. [insert more motivational clichés here] Your implementation of a registry, I'm not entirely sure of... It looks a lot like a singleton interface, which is probably what you're looking for. That, or just use globals / statics (ie. Database::$current/$instance/$default/etc) for your classes. It looks like you have the basic grasp of OOP, and all I can say at this point is browse around the PHP documentation for language/syntax info along with docs on libraries. In addition to that, find yourself a well-written or popular (one doesn't always imply the other ) library, a CMS, framework, some tutorials, what not, and browse around the source some, see what you find. Quote Link to comment https://forums.phpfreaks.com/topic/69700-small-framework-for-an-mvc-registry-pattern/#findComment-350320 Share on other sites More sharing options...
448191 Posted September 18, 2007 Share Posted September 18, 2007 Okay, so you've got part of the model and view... See something missing there? deadimp: it's a global Registry. Yes it's a Singleton, but also a pattern in it's own right and the most common implementation of Registry. Quote Link to comment https://forums.phpfreaks.com/topic/69700-small-framework-for-an-mvc-registry-pattern/#findComment-350349 Share on other sites More sharing options...
Mastodont Posted September 18, 2007 Share Posted September 18, 2007 The 'main module' (requested by user, think $_GET['mod']) will always be responsible for the main content (the body of the page). But every other module can also be loaded and create output for other parts of the page (like a poll in a block). Yes, it's one - probably good - approach. Or you could have relationship between URL and modules: site.com/articles (module articles goes into body) site.com/news (module news goes into body) Quote Link to comment https://forums.phpfreaks.com/topic/69700-small-framework-for-an-mvc-registry-pattern/#findComment-350485 Share on other sites More sharing options...
drcphd Posted September 18, 2007 Author Share Posted September 18, 2007 deadimp: thanks for the motivating words 448191: I thought I was missing the 'view' (for now). Wouldn't the Modhandler and modules be the controller? Mastodont: Yeah, I'm gonna do that: site.com/module/action/parameters So it's the OOP and whole idea I'm worried about. I don't want it to get dirty. Quote Link to comment https://forums.phpfreaks.com/topic/69700-small-framework-for-an-mvc-registry-pattern/#findComment-350640 Share on other sites More sharing options...
448191 Posted September 18, 2007 Share Posted September 18, 2007 Hmmm. I guess I was lead astray by the term 'module handler'... In effect, it's a Front Controller cq dispatcher. It's crude, but it'd work. Quote Link to comment https://forums.phpfreaks.com/topic/69700-small-framework-for-an-mvc-registry-pattern/#findComment-350658 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.