Hello I am hiring a PHP programmer for a website I need. One of the programmers said to me he would be using a framework, but I'm not too sure if this is a good or a bad thing. I've read on the internet about frameworks, and I have some doubts. If you use a framework, you probably only use 5% of it or something. Right? Won't this make the website slower then when it's completely custom made? Because of all the unnecessary code? I'm not talking about a website with 50uv/day but 50.000uv/day. Also when you're using a framework, you should probably update your code all the time because of newly found bugs. When you don't, the website is very vulnerable because the code of an open-source framework is on the internet for every hacker to see. Does that sound about right? For example, if I want a custom made arcade website with 50.000uv/day, would you use a framework? I'm not a PHP programmer, but I want to make the right choice when I hire someone.
I would use a MVC framework for pretty much any user-facing ecommerce application/site. You make valid points as far as security and speed go. However in my experience, the benefits outweigh the negatives in most cases. First off, a popular framework will have many developers working on it and thousands of users. It's rare that a major security threat is found after a framework goes into a production level build. IMO, this makes a framework more secure than most any single person code because there's people looking for vulnerabilities from the get-go. Also, libraries such as form validation are built in, making it much easier for a developer to sanitize and validate all user input as opposed to having to write validation on their own. If you use a framework by checking out a SVN or GIT repo, you can update the entire framework almost instantly, or write a script to check for newer versions and check out the new repo. As far as speed, a good framework will have a negligible reduction in speed compared to processing raw code assuming that the developer knows how to properly segment code, and the application is properly optimized, and it's on decent hardware with decent available bandwidth. Symfony 1.4, 2 and Codeignitor are very fast frameworks. I wouldn't hesitate to use any of them for small or very large web applications. The times when I would generally not use a framework would be back-end coding such as a web service / API, or a script that processes a large amounts or complex data without interaction of a user. Frameworks can work fine for these, but generally the script doesn't need V and sometimes the M part of MVC making the framework over complicated and clunky.
Depends on the framework he uses. CodeIgnitor and Yii are garbage, but I quite like Zend. FuelPHP and Laravel are also nice though not quite as feature packed. CakePHP is nice but I found it got annoying as my project grew. My opinion, of course.
Thanks for the comments. Why are CodeIgnitor and Yii garbage? The programmer I wanted to hire is using CodeIgnitor. Can anyone name me a few huge websites (lot's of visitors) which are based on a open-source framework?
Symfony: http://trac.symfony-project.org/wiki/ApplicationsDevelopedWithSymfony Noteably: Yahoo bookmarks - 20M+ users ted.com delicio.us aplus.net If those don't do it for you I'm not sure what would. Codeignitor does not have near as many large apps, but is a very fast framework. Yii is a solid framework IMO. Not a fan of cakephp in any way. Nothing beneficial over most any other php framework. They use a proprietary ORM which prevents using Doctrine or a 3rd party or open source ORM. Deal breaker for any real framework IMO. Zend has come a long way, but it's slow and large and up until recently vaguely resembled a framework but more a big bundle of libraries and classes.
Okay it's clear that frameworks are a great thing for developers, but what about the customers of a script? Apart from the reduced working hours/cost. Why are arcade scripts like: http://www.avscripts.net/avarcade/ http://www.phparcadescript.com/ http://www.onarcade.com/ and hundred of other scripts not created with an opensource PHP framework?
Many of these use Smarty as template engine probably. I used Smarty on my big project too. It's really powerful, small framework etc... David
IMO at some point every programmer (with productivity concerns) eventually uses a framework or at very least a vast number of pre-built libraries. There are so many tasks that you have to repeat on each project you get involved with, that sooner or later, you'll write some code that generically addresses that issue - even if we're not talking about a "public" framework (like those mentioned above), but just code that the programmer created along the way... Anyway the big advantages (on the client's perspective) of using a known framework would be the cost reduction (as you mentioned) and it will simplify the process of hiring another programmer to add features or correct something. It makes it easier for someone else to read and understand the logic behind the website, just because (correctly) using a framework "forces" the programmer to follow a number of standards. That being said, the benefit mentioned above is also the biggest downside on using a framework. It forces the programmer to do things in a certain way - if you'd like to do things other way you either hack into the framework's source code (which is a big no-no, as if an update of the framework is released, you'll probably be "stuck") or you develop the website from scratch, following whatever logic you'd like. As for any of the websites you mentioned, I don't see a valid reason to disregard the possibility of building them on top of a framework - but that's probably something you should discuss with your programmer, make sure he understands what your vision for the website is (plan now future features\additions). Good luck to your project!
It wouldn't hurt to use a framework. Your code would probably be a lot more organized and easier to maintain. But you better have some sort of Opcode cache system and/or FastCGI module installed since frameworks rely heavily on includes and components. I personally am against using universal frameworks. Most force you to follow by the standards they set for you and limit your productivity to their capabilities. Most major frameworks I've used are so bloated with bullshit to help make the easy easier... Personally I like creating my own patterns to follow by and using an MVC approach... They say a framework will speed up your development time...they neglect to tell you the learning curve will take longer than the raw development itself.
If your goal is to create a piece of software to sell (or offer) DO NOT use a Framework. The last thing a non-programmer wants to do when they purchase web based software is to then be forced to install libraries/modules/components. MOST popular web based software (wordpress, phpboard, ...) will be "plug and play". I would advise against a Framework in this case. If the code is for YOUR eyes only...do whatever you want. It won't matter....a framework would probably make it easier for your to maintain and grow.
If you bundle the framework files with the software, what's the problem? Laravel Framework uses a public domain license FYI.
Also, many frameworks have freeze functions that basically create a package with the required underlying framework and all of the coded app itself. It actually makes packaging a piece of software very easy. Apps like magento for example are based on a framework, Zend in Magento's case. These are very high quality php apps. Their existence and function alone is well worth the use of a framework.