Frameworks vs. Libraries in PHP (why I choose frameworks)

David Otton (who I’ve never met) has an interesting take on the old Framework vs. libraries debate, that I identify with.

I went through the same struggle (in my head) months ago. However, after having that internal struggle that David went through, I came out on the side of frameworks.

Why?
– Because frameworks allow me to get web applications up very quickly
– I don’t have to spend time figuring out or refining database access, templating or any of the other ‘plumbing’ that you have to do on most code projects. In fact there is a hobby site, that I wrote with my own custom code … and I haven’t made updates to it in months, because I have to entirely refactor the codebase to do the new things I want. If I had written it in cake (which I plan to port it over to). I’d have no such problems.
– I don’t have to completely relearn my code base after weeks away from it (part of the problem above too)
– Most frameworks include libraries of their own that you can use. In a recent project that I’m working on, there is a twitter gem for Rails that probably saved me (and the client) about 20 – 30 hours of coding, testing and bug fixing

What the article did tell me, though, is that developers the world over (especially PHP) developers are used to writing code from scratch. Designing, creating and implementing new ‘plumbing’ is a big part of what we do.

In any given framework, you’re going to like about 70% – 85% of what it does and (probably)absolutely hate the rest of it. Giving yourself over completely to convention-over-configuration framework like Cakephp when you don’t agree 100% with it is a big step for most developers. One that quite a few developer shy away from.

I think though, that if you find a reason to stick with it, like I did. You will find that the benefits of doing things with a framework will eventually overcome objections you might have to not having the framework do things … your way.