Symfony is a set of reusable and decoupled PHP components designed to solve common web development problems. While as a framework it might not be the best for some of your projects, you can always build on top of its solid foundation of well written, tested and flexible components.
Original presentation: https://docs.google.com/presentation/pub?id=136blt1DWJ95yuEdpmjz9dIqgg38VwEXBQlY7bu0Op8w&start=false&loop=false&delayms=3000
2. Who am I?
o Remembers symfony 1.0
(2007)
o Open Source contributor
o BDD advocate
o Works at Sensio Labs UK
o ZCE & Sensio Labs o Twitter: @jakub_zalas
Certi"ed Symfony o Blog: http://zalas.eu
Developer
o Github: @jakzal
3. What is Symfony?
First, Symfony2 is a reusable set
of standalone, decoupled, and cohesive
PHP components
that solve common web development problems.
Then, based on these components,
Symfony2 is also a full-stack web framework.
http://www.sxc.hu/photo/1197009 http://fabien.potencier.org/article/49/what-is-symfony2
4. Why does it matter?
* 76% of statistics found on the Internet is made up
http://www.sxc.hu/photo/1223174
12. $request = Request::createFromGlobals();
$session = $request->getSession();
if ($session->has('referrer')) {
$referrer = $session->get('referrer');
return new RedirectResponse($referrer);
}
if ($session->hasFlash('notice')) {
return new Response($session->getFlash('notice'));
} else {
$session->setFlash('notice', 'Hello again!');
return new Response('Foo')
}
13. $request = Request::createFromGlobals();
$date = getPageUpdatedAtById($request->query->get('id'));
$response = new Response();
$response->setPublic();
$response->setLastModified($date);
if ($response->isNotModified($request)) {
return $response;
}
// else do heavy processing to render the page
14. How to check if a request is made over ssl?
• is there HTTPS in the server vars? is it 'on' or '1'?
• or is there SSL_HTTPS header? is it 'on' or '1'?
• or is there X_FORWARDED_PROTO header set to 'https'
if ($request->isSecure()) {
// we're fine
}
39. $dispatcher->addListener(
KernelEvents::EXCEPTION,
function (GetResponseForExceptionEvent $event) {
$message = $event->getException()->getMessage();
$response = new Response($message, 404);
$event->setResponse($response);
}
);
HTTP/1.0 404 Not Found
Cache-Control: no-cache
Date: Sat, 06 Oct 2012 09:01:02 GMT
Unable to find the controller for path "/bye".
Maybe you forgot to add the matching route in
your routing configuration?
42. public function configure()
{
$this->setDescription('Outputs welcome message[...]');
$this->setHelp('Outputs welcome message.');
$this->addArgument(
'name',
InputArgument::OPTIONAL,
'The name to output to the screen',
'World'
);
}
43. $application = new Application('Demo', '1.0.0');
$application->add(new HelloCommand('hello'));
$application->run();
50. Why Symfony?
• Good code covered by tests
• Flexible
• Secure
• Stable API (@api annotation)
• Long term support
• Outstanding community
• Wide adoption
51. Thank you!
Rate my talk:
https://joind.in/6945
Interested in training?
We're introducing Symfony Components trainings soon:
http://www.sensiolabs.co.uk/training/symfony2.html