black.horizons Posted December 21, 2008 Share Posted December 21, 2008 Hey guys - i've been using PHP for 3 years - now i'm working on a website and I want to develop it in OOP - I've written a fully blown - and pretty advanced CMS in suquential code. I've got my head round writing PHP in OOP but on my site I've a couple of areas that I don't think needs OOP'd(?) - such as selecting lists of information. For these areas how would I write the code - as putting lists for navigation in as objects I think is overkill. Any and all ideas taken on board! Quote Link to comment https://forums.phpfreaks.com/topic/137940-solved-oop-question/ Share on other sites More sharing options...
448191 Posted December 24, 2008 Share Posted December 24, 2008 You'll need to provide a little more specifics (specifically, code) if you want to get help. But in general, I'd say there aren't many situations where OOP "isn't needed". Quote Link to comment https://forums.phpfreaks.com/topic/137940-solved-oop-question/#findComment-722997 Share on other sites More sharing options...
WhIteSidE Posted January 1, 2009 Share Posted January 1, 2009 You might consider the "Model-View-Controller" architecture. In php most MVC frameworks load a template type file which contains purely procedural code (or tags). See http://www.smarty.net/crashcourse.php and take a look at how cakePHP and CodeIgniter handle views. ~ Christopher Quote Link to comment https://forums.phpfreaks.com/topic/137940-solved-oop-question/#findComment-727588 Share on other sites More sharing options...
DarkSuperHero Posted January 1, 2009 Share Posted January 1, 2009 I would suggest thinking of your code and what it actually does, then split it down to different classes and functions.... eg in a cart project you would have; A Product Class would contains methods to deal with naming and pricing. extending the Product class to do deal Books, DVD's or Clothing. each putting forth their own methods, with parent class Products.... I would also suggest starting with the directory layout, and then coding the essential/core pieces of your project like the db connections, file handling...ect....im currently working on a project of my own....converting an existing procedural coded site to OOP... :-) Quote Link to comment https://forums.phpfreaks.com/topic/137940-solved-oop-question/#findComment-727633 Share on other sites More sharing options...
Liquid Fire Posted January 6, 2009 Share Posted January 6, 2009 I would also suggest using a MVC framework and then deal with elements of your site on a case by case base. Anything i build uses a custom MVC framework i have built which has a very small overhead for loading controllers and views. The model portion of my framework(usually some sort of ORM system that connects to a database) is the real bottle neck of the system(and should be for most MVC Frameworks) so there are case when i will use straight queries instead of the models. The most common example of something that might be in a database and i would not use a model for is navigation since most navigation is on multiple pages. Most other things i would only usually need a few dozen models(and if not it would be paginated data. Quote Link to comment https://forums.phpfreaks.com/topic/137940-solved-oop-question/#findComment-730982 Share on other sites More sharing options...
black.horizons Posted February 6, 2009 Author Share Posted February 6, 2009 guys thanks very much. should have "solved" this earlier. i'm now using smarty and loving it! Quote Link to comment https://forums.phpfreaks.com/topic/137940-solved-oop-question/#findComment-756108 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.