At last night’s NY-PHP gathering, a fellow PHP’er and I discussed PHP frameworks. I told her I was developing an e-commerce site using Zend Framework. She replied that she’d been considering frameworks, especially Cake and Symfony, “but I’m not sure I need a framework at all. I write my own SQL; my apps work fine. What would a framework do for me?”
Setting aside the differences between PHP frameworks, I’m aware of at least 4 reasons to use them:
- Modular design: A home-grown application, with its ad hoc growth, can become a tangled mess that’s hard to change or enhance. Most mainstream frameworks provide a modular design that makes it easier to modify or add components.
- Flexible components: Sure, you can write your own authorization class in PHP, but why reinvent the wheel? The framework will provide an integrated component that handles not only your current needs, but requirements that you haven’t yet encountered (but that the framework’s community has). With a framework, chances are that you won’t have to redesign your authorization system when the users ask for something new.
- Best practices: As you use the framework, you’ll begin to absorb the practices and (we hope) good habits of the framework’s creators.
- New capabilities: Frameworks regularly add functionality to help developers implement new technology. These days, common enhancements involve AJAX and connections to the APIs of popular web service providers.
Developers may understandably wonder if mastering a framework is worth the learning curve. In my opinion, the effort to learn a framework will be repaid with applications that are well structured, flexible, and easily maintained.