There are many different web application frameworks to choose from. PHP is the language of choice for most web developers, and it alone has several frameworks, such as CakePHP, CodeIgniter and Symfony. I've only used CakePHP, so I won't try to compare them. I will, however, explain in the context of web development just what a framework is, and why you'd benefit from using one.

When you make a website, whether it's the online equivalent of a library, newspaper or shop, or something radically new and interesting with no real world analogue, there are some things that it's pretty much guaranteed to need. You'll more than likely have to write code that lets people log into the site so that it knows who did what. You'll probably have to make a separate area for administrators that the general public can't see. As the database fills up, you'll also have to paginate data so that only a few articles or products are listed on each page, allowing people to flick through the list one page at a time.

All these things are common to most websites, so it's silly to write new code each time that does the exact same things as before. A much better way of working is to write all this functionality once, so that for your future projects, you can concentrate on what makes them different to the previous ones. To put it another way, it's a waste of time (and therefore money) to reinvent the wheel with each new project.

Frameworks make sure you don't have to write your programs from scratch anymore. They provide two main advantages over coding everything by hand.

Probably the least important of the two (yet still important in its own right) is that they include conventions. You won't have to spend any time making the decision, for example, of whether to pluralise the names of tables in the database. CakePHP, for example, encourages you to always pluralise them, because by convention that's what it looks for, and your life will be much easier if you stick with its conventions.

The other advantage is that frameworks have a lot of code already built into them. CakePHP has code that writes forms, code that paginates data, code that authenticates people, and code that does pretty much anything else that you're likely to need on most websites. It's a pretty safe bet that most other web application frameworks have all of these things covered too.

These frameworks use object oriented PHP, specifically the MVC paradigm, which is something interesting enough to warrant a whole separate article. Suffice it to say that this paradigm separates code related to storing and retrieving data, code related to the user interface, and code that works out the logistics of what should happen next, in much the same way that CSS files enable you to separate semantic text and styling information.

The upshot of the MVC paradigm is that your code will become far more logically laid out and far less haphazard. Instead of rewriting a given block of code on each page where it's called, you can write it once where it can be reused from one page to another. While this may slow you down slightly at first when it comes to actually writing the code, it will greatly speed you up as the project progresses.

This is partly due to how the paradigm encourages re-use of code, and partly how it just makes things easier to find. Although it may seem like a trivial advantage at first, you'll appreciate it when you come back to your project several months later and try to work out where a particular line of code might be. It also makes it easier to collaborate with other people, as they too will be able to work out where to look for a specific line of code.

Even if working out the correct way of doing something may slow you down slightly at first, you'll still be programming much faster than you would be by yourself because you can take advantage of all the code that's already been written for you -- standing on the shoulders of giants.

Considering that using a framework saves you a lot of time when building any project (except for perhaps the first, as it takes a while to get used to the new way of working), and it doesn't cost you anything, there's no reason anymore to stubbornly write whole projects from scratch, except perhaps for scalability if your project truly requires it. Switching to CakePHP has saved the company I work for a lot of time and therefore money. If you write websites for a living and you haven't yet tried using a framework, I'd thoroughly recommend you check one out as soon as possible.

Log in or register to write something here or to contact authors.