Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Guest blogger Josette Rigsby has over 15 years experience in leading technology teams and delivering solutions. She has a special interest in enterprise architecture and emerging technology.

PHP has ranked as one of the most popular programming languages for over a decade. The loosely typed language has a long list of built-in functions, simple syntax and very few rules, which makes it a “go to” tool for countless developers. PHP’s ability to get things done fast continues to attract legions of new enthusiasts, which is why it is a bit surprising that the PHP development community is still divided regarding frameworks.

Everybody’s Doing It?

The buzz around frameworks like CakePHP, Zend, CodeIgniter and even SilverStripe’s recently decoupled framework (formerly known as Sapphire), might give a casual observer the impression that the majority of PHP developers have embraced frameworks to standardize and speed their development.

They haven’t.

The recent MicroPHP Manifesto, which passionately argues against the current direction of most popular PHP frameworks, has refocused attention on the topic. Although the manifesto subtly states frameworks aren’t “necessarily bad” multiple times, you could easily get the impression that PHP frameworks are large and complex code beasts that eliminate the key benefit of the language- simplicity. Armed with this knowledge, you could then shed the oppressive constraints of the framework you loved only three months ago and become one with the code – rolling your own functions and stringing together micro frameworks to build an application that reflects your true spirit.

 

 

 

 

 

 

 

 

 

 

 

Slow down there, tiger.

Why Frameworks?

Frameworks aren’t all bad, and you should not discount frameworks just because they require time to learn or slightly increase complexity. If your goal is to create SOLID instead of STUPID code, leveraging a framework is often a good choice. However, there are scenarios where you should avoid frameworks:

  • Industries or organizations where regulations or policies discourage or prohibit use
  • Small or simple sites with mostly static content
  • Applications with exceptionally demanding performance requirements
  • Projects that involve making only a few enhancements to a large and established code base

For everything else, you should at least consider using a framework.

Using a framework is not without costs. You must take the time and effort to select, learn and eventually upgrade the framework. (TIP: If you are on a team with more than 2-3 people, consider having a lunch and learn to accelerate the process.) Although frameworks typically handle the most common scenarios, they may not address your specific use case. If this occurs, you will need to invest time in figuring out how to solve the problem. Many frameworks include extension mechanisms to make adding functionality easier. Finally, leveraging a framework means giving up some control. You must trust that the creators of the framework leveraged good design practices. You must trust that they tested. You must trust that they will not make breaking changes.

No tool is a silver bullet, but if you select a popular framework, you are likely getting a better product than you would have created internally. Many frameworks, like SilverStripe’s, are based on years of experience implementing content management functionality across multiple industries and organizations; unless you are lucky, your project team doesn’t include the same depth of experience. Further, many open source PHP frameworks have hundreds of contributors and thousands of users that provide a rich source of collective knowledge and peer review. This usually results in a solution with fewer defects and a better design.

A better code base isn’t the only benefit of leveraging a framework. Frameworks can:

1. Standardize Architecture – Most frameworks incorporate design (e.g. decorator) or architectural (e.g. MVC) patterns. Using the framework incorporates the pattern into your project. Additionally, frameworks can impose other structural constraints like file system organization, which make it easier for multi-member teams to deliver a solution. Micro frameworks can provide value in this area, but if you need to use more than one, you may have to deal with conflicts and inconsistencies in how they are organized. Obviously, using a framework isn’t the only way to achieve architectural consistency, but a framework can make it simpler.

2. Minimize Infrastructure and Utility Development – Frameworks often implement infrastructure concerns like caching, data connections, logging and security. These commodity features are required, but don’t significantly contribute to business value. If you don’t feel an urge to twist wires for your own USB cables, you shouldn’t feel a need to write lines of code to produce a log file. Don’t reinvent the wheel; spend your time designing and delivering core solution features.

3. Provide Broad Support Options – If you write your own framework, you and your team are the only source of knowledge about its use. If you use a framework you get forums, documentation, other users and potentially third party solution providers to help you solve problems.

4. Reduce Staff Onboarding Time – If you select an existing, widely used framework, it is possible to add staff that already know the framework. This reduces the time and cost associated with onboarding new resources. You should not underestimate the value of this benefit. Labor is significantly more mobile than in the past. It’s not uncommon for all members of an original implementation team to leave an organization before an application is retired. When there are no humans available to guide a new developer, the use of a framework can provide tremendous value.

5. Reduce Technology Debt – One of the benefits of frameworks you might have overlooked is reduction in technology debt. Teams often eliminate items that don’t contribute directly to business value (e.g. configurable logging) to complete a project on time. Unfortunately, these small concessions can have large and long lasting negative impacts. Using a framework allows you to get many of these often omitted features without investing the time to design, develop and test them.

I am not suggesting developing custom code or using a micro framework is bad. Every problem is different and these techniques are the right solution to some problems. However, sometimes implementing the fastest easiest solution on a micro level can result in complete chaos at a macro level. Do you use a PHP framework? Do you feel that it has benefited your solution delivery? We would love to hear your thoughts.