I am working on a very simple custom CMS based on Model/View/Controller. I am doing it so I can learn more about PHP and this will force me. My system is not perfect and my question is not whether it has right structure or not.
But its one specific question. Following is my structure
------ Get RSS from external site and store in database (run using cron)
Now, I need to show 5 latest RSS feeds in index.php. Should I create a model/rss.php? Or should I create a RSSDB class in package (package/rss/rssdb.php) which can grab those entries?
I may or may not have an RSS Model/View/Controller in future. And it may or may not have to do with same tables. Although, if that happens then does it mean I keep using rssdb.php?
As you can see, I am quite confused. Can you please help?
If your motive of making package is to keep things independent (almost like plugin) then may be one idea can be to have
model,view and controller with in that package folder or may be inside rss folder and put database access in model of that making a page...
that is how ,many standard scripts do...
There's not really a set rule, but I generally keep models for things that are going to be persisted (ie stored in the database), and then create what I call "service" classes for doing things like this, so I'd probably split it out into a service class that is able to read from your rss feed, and then create a separate model if you actually want to store the data anywhere. That way you've got a nice clean interface for reading the rss, and another separate one for persisting it if you need to do that.
So I guess my answer would be to do both - keep the model/rss.php just for saving the data to the database, and have the service/package class do the work involved in actually reading the rss feed and grabbing the data.
(Also, I'm fairly sure what I'm referring to as a service is the same as what you're referring to as a package).
This topic is now closed. New replies are no longer allowed.