A web framework is a framework designed for the development of dynamic websites, web applications, or web services. Repetitive tasks are simplified, and code reuse and software development self-documentation are encouraged. Concepts such as Don’t repeat yourself, KISS or convention before configuration offer simple, clear structures that can be maintained with little effort.
Through predefined and pre-built classes, frequently used functions such as mail sending, secure authentication and authentication, security functions, localization, performance (e.g. HTTP caching) or basic functions for web forms are brought from the framework.
Web frameworks are designed to create web applications that run very quickly. To this end, today’s web frameworks offer database access, templating mechanisms, a clean separation of presentation and code by using the Model View Controller or Model View Presenter as an architectural pattern, as well as often opportunities for rapid prototyping through scaffolding.
Most web frameworks offer database access, usually via an object-relational mapping. For ease of use, there is often an object-relational mapper that takes care of persistence and offers ready-made classes for use. This can be done explicitly, as in Django, or implicitly via introspection, as in Ruby on Rails.
Some web frameworks include a database abstraction layer as a standalone framework, such as Doctrine in Symfony.
An existing database that has already been described with data cannot simply be replaced, like the software itself. Many web frameworks offer migrations, subroutines that adapt the database structure, in order to automatically execute necessary database changes.
Database access from the GUI is generally considered controversial in computer science. For example, the often encountered strict layer architecture with three layers generally prohibits access from the presentation layer to the persistence layer. Also, the MVC pattern, which is often used in web frameworks, does not allow database access from the GUI (but only via the model).
A web framework also usually offers the possibility to control the display via a template engine. To do this, HTML pages are generated on demand, which are filled with the dynamic content. At this point, it is usually possible to separate static and dynamic content, so that a designer, for example, determines the appearance by designing a template, which the application developer then fills with data. The syntax of the template languages is usually based on HTML or only slightly expands on it.
Scaffolding supports the developer in development and prototyping by generating CRUD pages (Create-Read-Update-Delete). This makes it possible to offer a web interface directly from the design of a model, for example, through which data can be entered and managed immediately into the database. In this way, it is already possible to develop and test with sample data. The admin interfaces of a web application can also be generated with scaffolding, as these often only require basic controls.
The definition of the URLs of the web application can usually be configured in the web framework, similar to .htaccess. Clean URLs, redirects, and error messages can be set.
Sinatra – a web framework based on Ruby
Ruby on Rails – an MVC web framework based on Ruby
Symfony – a PHP-based MVC web framework
CodeIgniter – lightweight PHP framework