Development · Term

Framework

A framework is a ready-made foundation of code and conventions that developers build an application on, providing common parts such as page routing, database access, forms and security so they are not written from scratch.

A framework sets the structure and calls your code at the right moments; a library is a toolbox your code calls when it needs something. The difference sounds academic, but it explains why switching frameworks usually means rebuilding, while swapping a library often does not. Laravel and Symfony for PHP, Django for Python and Next.js for JavaScript are common examples.

A framework is also different from a CMS. A CMS such as WordPress is a finished product for managing content that you can extend; a framework is raw material for building something bespoke, and has no editing screens until a developer builds them.

How it works

A framework provides a skeleton: where files go, how a web address maps to the code that handles it, how data is read from the database, how forms are checked and how pages are rendered. Developers fill in the parts specific to the project, such as the booking rules or the product catalogue, and the framework handles the plumbing around them.

Most frameworks also bundle defences against common attacks, such as protection against forged form submissions and safe ways to query the database. Using those defences properly is one of the main reasons to choose a framework over writing everything by hand, because home-made security code is where many small applications go wrong. The defences only help when developers use them as intended rather than bypassing them for convenience.

Frameworks are maintained by their communities or companies and release updates regularly, including security fixes. Each major version is supported for a limited time. A project that never upgrades eventually runs on a version that receives no more fixes, and the jump to a current version grows larger the longer it is left.

Example

A clinic wants a patient portal where patients book appointments, fill in forms before their visit and see their upcoming visits. A developer builds it on an established framework. Logins, password resets, form validation, email sending and database access come from the framework; the developer writes the clinic-specific parts, such as which treatments need which forms.

Three years later the framework version it uses reaches the end of its support. Because the developer kept to the framework's conventions and kept dependencies up to date, the upgrade takes days rather than weeks. A similar portal built with heavy custom workarounds would have needed far more rework to follow.

Why it matters for your business

The framework your project uses affects cost for years: how easy it is to find developers, how quickly features can be added and how much upkeep is needed. Popular, well-documented frameworks are the safer business choice because help is easy to find and security fixes keep coming. A framework is also often the wrong tool for a simple marketing site, where a CMS or a static site gives you editing screens and lower running costs without bespoke development. When you get a quote, ask which framework will be used and how long its current version is supported, and budget for upgrades as part of normal upkeep.

Common mistakes

  • Choosing an obscure or fashionable framework that few developers know, making future help scarce and expensive.
  • Building a bespoke application on a framework when an existing CMS or service already does the job.
  • Never upgrading the framework after launch until the version is long out of support.
  • Working around the framework's conventions so heavily that upgrades and new developers struggle.

Questions people ask

What is the difference between a framework and a library?

A library is code your application calls when it needs a specific task done, such as formatting dates. A framework provides the overall structure and calls your code at set points. You can usually swap a library; swapping a framework usually means rebuilding much of the application.

Is WordPress a framework?

WordPress is mainly a content management system, a finished product for publishing and managing content. Developers do build plugins and custom features on it, so it can act like a platform, but it is not a general-purpose application framework in the way Laravel or Django are.

Which framework should my website use?

It depends on what the site does. A content-led site often needs a CMS rather than a framework. A custom application suits a mainstream framework that your developer knows well and that your hosting supports. Popularity, documentation and long-term support matter more than novelty.

Related terms

Have something worth building right?