The document introduces Symfony, an open-source PHP web framework. It discusses how to install Symfony using Composer, and provides examples of using key Symfony components like the class loader, routing, dependency injection, and more. The document encourages readers to try Symfony themselves and notes that it can become addictive due to its features and standards compliance.
16. What are the Symfony components?
Symfony components are:
– Set of independent components
– Each can be used separately
– High quality coded, tested and documented
Symfony components are just bricks but you're
completely responsible to glue them
17. The list of Symfony2 components
Class loader
Config
Console
CssSelector
Dependency Injection
Form
Event Dispatcher
Http Foundation
Http Kernel
Routing
Security
Yaml
18. What is bundle
Bundle — set of files which implement single
feature
Generate bundle skeleton
$ php app/console generate:bundle
--namespace=BundleFolder/NameBundle
--format=annotation
31. Symfony and inspiration
How to rescue your PHP project with Symfony2
components
http://habrahabr.ru/post/146521/
http://www.slideshare.net/xavierlacot/symfony2-
components-to-the-rescue-of-your-php-
projects
32. Create your own framework on top
of Symfony components
Recipe from Fabien Potencier
http://fabien.potencier.org/article/50/create-your-
own-framework-on-top-of-the-symfony2-
components-part-1
33. Symfony2 components: Console
Some examples of usage
$ php app/console doctrine:generate:entities
Name/MyBundle/Entity/SomeEntity
- generates getters and setters for SomeEntity
$ php app/console container:debug
list of all available services
40. Benefits:
Only one instance of Mailer which can be used
in entire application
Centralized configuration of Mailer
It can be replaced by another service
41. Services container (DIC)
Step 1: Create class
Step 2: Register it as service by adding to the
service container
Step 3 ... n: Use it
52. Events and listeners
Event 1 in HttpKernel->handle(): kernel.request
I.e. Security listener can throw Response object
with 403 Access denied response
54. Symfony2 is very fast
Response class to manage HTTP cache:
$response = new Response();
$response->setMaxAge(600);
$date = new DateTime();
$date->modify('+600 seconds');
$response->setExpires($date);