Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint...
Transcript of Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint...
![Page 1: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/1.jpg)
Symfony
from a Bird’s Eye View by Philipp Rieber
@bicpi
Joint Drupal-Symfony User Group Munich, Feb 17th 2016
![Page 2: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/2.jpg)
• My name is Philipp Rieber
• I am a PHP developer
• I work at
• I tweet @bicpi
• I have a homepage at http://philipp-rieber.net
ABOUT://ME
![Page 3: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/3.jpg)
WHAT IS SYMFONY?
“First, Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP components that solve common web development problems.”
[Fabien Potencier]
![Page 4: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/4.jpg)
BrowserKit
ClassLoader
Config
Asset
Console
CssSelectorDebug
DependencyInjection
DomCrawler
EventDispatcher
ExpressionLanguage
Filesystem
Finder
Form
Guard
HttpFoundation
HttpKernel
Icu
Intl
Ldap
Locale
OptionsResolver
Process
PropertyAccessPropertyInfo
Routing
Security
Serializer
Stopwatch
Templating
Translation
Validator
VarDumper
Yaml
![Page 5: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/5.jpg)
BrowserKit
ClassLoader
Config
Asset
Console
CssSelectorDebug
DependencyInjection
DomCrawler
EventDispatcher
ExpressionLanguage
Filesystem
Finder
Form
Guard
HttpFoundation
HttpKernel
Icu
Intl
Ldap
Locale
OptionsResolver
Process
PropertyAccessPropertyInfo
Routing
Security
Serializer
Stopwatch
Templating
Translation
Validator
VarDumper
Yaml
![Page 6: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/6.jpg)
require 'vendor/autoload.php';
use Symfony\Component\Yaml\Yaml;
$yaml = <<<YAMLparameters: user: symfony pass: awesomeYAML;
$config = Yaml::parse($yaml);// ['parameters' => ['user' => 'symfony', 'pass' => 'awesome']]
$ composer require symfony/yaml
Yaml Component
![Page 7: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/7.jpg)
BrowserKit
ClassLoader
Config
Asset
Console
CssSelectorDebug
DependencyInjection
DomCrawler
EventDispatcher
ExpressionLanguage
Filesystem
Finder
Form
Guard
HttpFoundation
HttpKernel
Icu
Intl
Ldap
Locale
OptionsResolver
Process
PropertyAccessPropertyInfo
Routing
Security
Serializer
Stopwatch
Templating
Translation
Validator
VarDumper
Yaml
![Page 8: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/8.jpg)
$ composer require symfony/finder
Finder Component
require 'vendor/autoload.php';
use Symfony\Component\Finder\Finder;
$finder = new Finder();
$finder ->in('/Users/bicpi/photos') ->files() ->name('*.jpg') ->size('>= 1M');
foreach ($finder as $file) { echo $file->getFilename() . "\n";}
![Page 9: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/9.jpg)
Separation of Concerns
“Do one thing. Make it excellent.
Stay out of the way.”
• … • Console Command Line Interfaces • Filesystem Basic utilities for the filesystem • Translation Tools for internationalisation • …
[Unix Philosophy]
![Page 10: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/10.jpg)
WHAT ELSE IS SYMFONY?
“Then, based on these components, Symfony2 is also a full-stack web framework.”
[Fabien Potencier]
![Page 11: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/11.jpg)
BrowserKit
ClassLoader
Config
Asset
Console
CssSelector
Debug
DependencyInjection
DomCrawler
EventDispatcher
ExpressionLanguage
Filesystem
Finder
Form
Guard
HttpFoundation
HttpKernel
Icu
IntlLdap
Locale
OptionsResolver
Process
PropertyAccessPropertyInfo
Routing
Security
Serializer
Stopwatch
Templating
Translation
Validator
VarDumperYaml
Your Application
![Page 12: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/12.jpg)
Request Response
It is all about transforming a Request into a Response
☺
Symfony full-stack
![Page 13: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/13.jpg)
HttpFoundation\Request HTTP Header, $_GET, $_POST, $_COOKIE, $_SESSION, $_SERVER
HttpFoundation\Response HTTP Status Code, HTTP Header, Content (HTML, JSON …)
HttpKernelWeb framework core, “Glues” the components,
Loads configuration and “Bundles”, Controls flow
![Page 14: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/14.jpg)
Request
Response
/blog/article?id=34
class BlogController extends Controller{ /** * @Route("/blog/article") */ public function articleAction(Request $request) { $id = $request->query->get('id'); $article = $database->findArticle($id); if (!$article) { return new Response('Article not found.', 404); }
$html = $view->renderArticle($article);
return new Response($html, 200); }}
![Page 15: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/15.jpg)
• Routing Match URL to controller action
• Templating Render templates
• Security Decide about access
• Config Load configuration
• Forms Create HTML forms
• DependencyInjection Decouple your services
• …
During the Request ➾ Response flow, many more components will assist
![Page 16: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/16.jpg)
BUNDLES• ~ PlugIns, but even better
• Everything in Symfony Full-Stack is a Bundle
• Yes, Symfony Full-Stack itself is a Bundle
• Core and custom code is in Bundles
• Registered in HttpKernel
![Page 17: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/17.jpg)
• PSR – PHP Standards Recommendations
• HTTP Specification
SYMFONY ♥ STANDARDS
![Page 18: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/18.jpg)
• Git & GitHub • Semantic Versioning – Breaking.Feature.Fix • Dependency Injection • Event Driven • Popularize ORMs • New level of code quality and architecture • Command Line Tools
INNOVATIONS
… just to name a few
(in the PHP world, at least …)
![Page 19: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/19.jpg)
• Twig
• Composer
• Monolog
• Swiftmailer
• Silex
• PHP CS Fixer…
SYMFONY “BY-PRODUCTS”
![Page 20: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/20.jpg)
• Outstanding Documentation
• Huge ecosystem of 3rd-party bundles
• Creates many “celebrities”
• Conferences
• Certification
SYMFONY’S COMMUNITY(and SensioLabs)
![Page 21: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/21.jpg)
Evolution, not Revolution
SYMFONY 3
![Page 23: Symfony - Philipp Rieber · Symfony from a Bird’s Eye View by Philipp Rieber @bicpi Joint Drupal-Symfony User Group Munich, Feb 17th 2016 • My name is Philipp Rieber](https://reader030.fdocuments.net/reader030/viewer/2022040203/5e88d6c520b1076c9b449920/html5/thumbnails/23.jpg)
• http://symfony.com/ • https://github.com/symfony • http://fabien.potencier.org/what-is-symfony2.html • http://symfony.com/doc/current/create_framework