Introduction
In a nutshell, frameworks provide a layer of abstraction that sits on top of the native php code. This layer of abstraction comes in the forms of classes and methods that the developer can use to build their applications.
The advantages of frameworks
Decreases development time
A framework packages common functions into convenient classes and methods that make it easy for the developer to perform common functions quickly. For example, let’s say the developer needs to parse out XML. They can use an XML parsing class that then gets stored in a library. From now on, they can use that XML class on all their other projects and won’t need to rewrite any code.
Increased Security
A good PHP framework will have security features built in that are implemented transparently (without the input of the developer). For example, a framework can check input values from a form field before it gets inserted into the database.
Easier to maintain
It’s much easier to maintain a framework because all of the elements are organized into separate parts that are arranged by context. You won’t have to hunt throughout your code to find out why your dates aren’t being parsed correctly, you simply go to your date classes and find the bug.
Multiple developers benefit from a framework because they each share an identical picture of the entire system in their head. They automatically follow a set of rules and regulations that are enforced by the system itself. So that if either of them deviate from the system, the program simply won’t work.
Highly extensible
Good frameworks break up each feature into independent parts which can be inserted and removed at a whim, this makes it easy for developers to expand the system through plug ins and modules.
Large community behind it
Mature frameworks usually have a large community of enthusiastic and passionate developers who are ready to answer and ask questions. This is invaluable for resolving bugs and addressing specific problems.
The disadvantages of frameworks
Increased overhead
The more files you include the more work the server has to do in order to run the system. Some frameworks can be pretty large and it’s not uncommon to see it using hundreds if not thousands of files.
Fortunately, most frameworks come with a caching system that dramatically reduces the impact on the server.
For most small to medium size sites frameworks typically do a good job at keeping a low footprint.
Large learning curve
Frameworks can take a long time to learn. Especially for those who are unfamiliar with object oriented programming. It can take from a few days to a few weeks to learn a framework enough to be considered competant.
The internals are hidden from the developer
Frameworks do such a good job at hiding the php behind the framework that it’s easy to bypass learning PHP completely. This can be detrimental if you’re trying to learn php so I wouldn’t advise you to start learning a framework until you already have a firm hand on php and have some knowledge of object oriented programming.
Less flexibility
Your options are reduced substantially when you start using a framework. With a framework you are usually limited to one or two ways of doing something. For example, you may be required to return data as an object instead of an array. This is actually a blessing in disguise. By limiting the way you work you start to create a sense of “sameness” across the system that makes it much easier to know what’s going on at a glance.
Build your own framework
For those who are new to object oriented programming or PHP frameworks I recommend you build your own. It will give you a clearer idea how frameworks and some of the things that you have to take into consideration, such as security, url parsing, file structure etc.
You will learn a lot and be better prepared to start working with some of the mature frameworks that are available on the web.
Download a framework
There are a lot of quality frameworks available on the web but I’ve chosen four of my favorites for your consideration.
CakePHP
This is one of the most popular frameworks and it encourages a rather strict implementation which is great for teams of web developers and beginners. If you’re just getting your feet wet and want to try out a powerful framework with a strong community then I would recommend this one.
CodeIgnighter
This is my personal favorite, It is similar to CakePHP but is more flexbile, I based my own framework off of this one (with some of my own changes).
Zend Framework
This is developed by the people behind PHP. It is very comprehensive and takes a different approach than PHP Igniter or CakePHP in that it provides the pieces for you to work with but you are responsible for getting them to work together.
PEAR
PEAR is more of a repository than a framework but it’s worth adding to the list because all the code adheres to strict rules and can be integrated together.
What are your thoughts?
Do you use a framework? If so what do you use?