February 16th, 2013, 05:28 PM
When to use a web framework
I've been web programming in PHP/MySQL for a while, but have never used a framework. I have a project now with the potential for high traffic, and I'm not sure that the code I usually write by hand is scalable enough to handle that. I'm wondering if the code generated by a framework is made to be scalable, or if it still depends on the skill of the coder.
I'm also wondering whether it depends on the kind of site. My site has a lot of user interaction, so the data pulled for a given page can change based on user input, and is updated on a pretty regular basis. I've heard that frameworks are better for large collections of non-interactive pages, but I'm not sure if that's true.
Finally, does anyone have any recommendations for someone who is new to the framework world?
February 16th, 2013, 10:23 PM
Good performance scalability has a lot to do with good database design, a lot to do with writing your SQL queries correctly, a little to do with not writing dumb PHP code, and not a whole lot else. A framework will not help much, if at all, when it comes to performance scalability.
The primary purposes of a framework are (a) to provide a roadmap for a high-level architecture design (usually MVC) and (b) allow code to be re-used between projects more easily. Both of these are intended to improve development scalability - the ability to change and reuse code later without having to rewrite large amounts of other code.
Standard frameworks are primarily useful for sites that have non-trivial code and not super-high traffic. If the code is simple, then the framework adds more programming overhead than it's worth. If the site is super-high traffic, then the framework adds too much performance overhead.
However, even though you say "high traffic", I doubt the traffic of your site will be high enough to the point where a framework would hurt performance. Additionally, "potential" for high traffic is not the same thing. Using a framework is a wise choice, but prematurely optimizing code because you think you might have high traffic someday is not.
A content management system is best suited to large collections of non-interactive pages. This would be something like Drupal, WordPress or Joomla. They are not particularly well suited to any other type of site, although many developers (ab)use them in this way.
A framework would be something like CodeIgniter, Yii or Zend. I recommend CodeIgniter as it has hands down the best documentation and the least complicated design of any major PHP framework.
February 16th, 2013, 10:34 PM
Thanks E-Oreo, this helps a lot.
February 17th, 2013, 11:41 AM
sorry, i hope you dont mind me posting a question:
i am doing a project and using MVC and it has gotten to a point where because of the three separate files for each functionality, it is getting a bit hard to keep track and i have to open all three (M, V, C) when i work on a functionality..
SO the question is how should i "manage/track" it all?
I would love to go back to simple OOP but i am half way into the project and do not necessarily want to switch. I may just re-code/optimise the site once the project is actually working..
February 17th, 2013, 01:14 PM
The point of MVC is generally to split the three components into separate files, so there is not really a way around editing three separate files.