Symfony: Build your App, not your Tools¶
You now know that the goal of any app is to interpret each incoming request and create an appropriate response. As an application grows, it becomes more difficult to keep your code organized and maintainable.Invariably, the same complex tasks keep coming up over and over again: persisting things to the database, rendering and reusing templates, handling form submissions, sending emails, validating user input and handling security.
The good news is that none of these problems is unique. Symfony provides a framework full of tools that allow you to build your application, not your tools. With Symfony, nothing is imposed on you: you're free to use the full Symfony Framework, or just one piece of Symfony all by itself.
Standalone Tools: The Symfony Components¶
So what is Symfony? First, Symfony is a collection of over twenty independent libraries that can be used inside any PHP project. These libraries, called the Symfony Components, contain something useful for almost any situation, regardless of how your project is developed. To name a few:
HttpFoundation
Contains the Request
and Response
classes, as well as other classes for handling sessions and file uploads.
Routing
Powerful and fast routing system that allows you to map a specific URI (e.g. /contact
) to some information about how that request should be handled (e.g. execute the contactAction()
method).
Form
A full-featured and flexible framework for creating forms and handling form submissions.
Validator
A system for creating rules about data and then validating whether or not user-submitted data follows those rules.
Templating
A toolkit for rendering templates, handling template inheritance (i.e. a template is decorated with a layout) and performing other common template tasks.
Security
A powerful library for handling all types of security inside an application.
Translation
A framework for translating strings in your application.
Each one of these components is decoupled and can be used in any PHP project, regardless of whether or not you use the Symfony Framework. Every part is made to be used if needed and replaced when necessary.
The Full Solution: The Symfony Framework¶
So then, what is the Symfony Framework? The Symfony Framework is a PHP library that accomplishes two distinct tasks:
Provides a selection of components (i.e. the Symfony Components) and third-party libraries (e.g. Swift Mailer for sending emails);
Provides sensible configuration and a "glue" library that ties all of these pieces together.
The goal of the framework is to integrate many independent tools in order to provide a consistent experience for the developer. Even the framework itself is a Symfony bundle (i.e. a plugin) that can be configured or replaced entirely.
Symfony provides a powerful set of tools for rapidly developing web applications without imposing on your application. Normal users can quickly start development by using a Symfony distribution, which provides a project skeleton with sensible defaults. For more advanced users, the sky is the limit.