Here at Factor 3 we use PHP to develop our client’s websites. One reason for this is that PHP is a fantastic language to use - in fact it’s used to run many popular websites including Facebook and Wikipedia. A big part of why it is so popular is the fact that it has such a low barrier to entry. Setting up a local environment to run PHP is just a few mouse clicks and there is an excellent range of PHP hosting available when you come to putting your website live.
With it being so easy to write, it is very tempting to just start coding straight away when starting a new project. However, for all but the most basic projects, you should definitely consider using a framework. A framework provides you with many of the common components required to develop a website – for example, database access, templating systems and authorization systems. Popular PHP frameworks include Zend Framework, Symphony, CakePHP and CodeIgniter. These frameworks are all open source – which means that anyone can review and suggest improvements to the code. Using a framework provides you with many benefits:
Saving time – a framework will provide a large base of generic code, which means that you don’t have to write your own libraries for things like login systems or user input handling. You will spend a much greater percentage of your time actually developing the results you need, rather than developing the surrounding functionality required to achieve the results required. In order to stay competitive, web design and development agencies need to make sure their development environment is as efficient as possible.
Reliable – each part of the code that forms the framework will have been developed by experts in that particular area of programming, and continually tested, reviewed and improved. For instance, Zend Framework has scores of contributors, many of whom are world experts in their fields. There is no way that a custom software system could compare to a popular framework. This reliability is particularly important when it comes to security – I sleep much better at night knowing that the security code in the sites I’ve developed is written by world experts.
Patterns – Frameworks are normally built around the MVC design pattern, which helps you keep the different parts of your code well structured. You can of course create your own MVC structure, but with a framework, it is all there ready to use. Frameworks also use many other design patterns which promote effective programming – this will both benefit your progress as a developer, and help improve your code itself.
Community – All of the frameworks mentioned above have active communities with hundreds if not thousands of developers using them and discussing their use. These communities are always helpful if and when you come up against an issue. Getting involved in these is always a great way to help you improve as a developer as you can learn the best way of solving problems, and new ways of doing things more easily.
So you might be thinking that the use of a framework is all good news, but there are a couple of disadvantages:
Learning curve - Compared to just using PHP, understanding an extra layer will of course take a little longer. This does vary between the frameworks, with CodeIgniter being particularly easy to get started and Zend Framework having a rather steeper learning curve. However - this disadvantage is only short lived, as once you are up to speed with using the framework, you’ll be significantly more productive.
Performance - All the extra functionality that frameworks provide means more lines of code that your server has to process on every request. However, most frameworks provide built in caching which you can enable with just a few lines of code – this will allow your site to easily match, if not beat a non-framework solution. You could of course write your own caching system, but this would take time, whereas it is all there, ready to go, with a good framework.
In conclusion, there are numerous advantages to using a framework, and the disadvantages are either short-lived, or easily quashed. Whether or not to use a framework should be a fairly straight forward decision. If you are building an application - i.e. something that couldn’t just be static html - then a framework would most likely benefit you in the long run. If you’re not currently familiar with a framework, the most difficult choice will be which framework to use. But that’s a topic for a whole new blog post.
Add a comment