Welcome to the
       Symfony2 World



            Lukas Smith    Daniel Kucharski
             @lsmith        @inspiran_be


Saturday, February 2, 13
Speakers
          Lukas Kahwe Smith


                           • Developer at Liip AG in Switzerland
                           • PHP 5.3 co-release-manager,
                           • Contributing to Doctrine, Symfony,
                             PHPCR ..



Saturday, February 2, 13
Speakers
          Daniel Kucharski


                           • SAP Business Consultant by day
                           • PHP enthusiast at night since 2000
                           • Co-founder of the Vespolina Ecommerce
                             Project



Saturday, February 2, 13
What is Symfony2?
                     • Symfony2 is a reusable set of standalone,
                       decoupled and cohesive PHP components
                     • Symfony2 is also a full-stack framework
                     • MIT licensed (permissive, GPL compatible)
                     • Compliant with PSR-0 , PSR-1, PSR-2, PSR-3
                     • https://github.com/symfony/symfony


Saturday, February 2, 13
What is Symfony2?
                     • Approaching 700 contributors
                     • Most popular PHP project on github.com
                     • First stable release in July 2011
                     • LTS release with 5 year support in May 2013
                     • Used on many big sites: ted.com,
                           lockerz.com, opensky.com, exercise.com,
                           wetter.de, stern.de ..


Saturday, February 2, 13
Components




Saturday, February 2, 13
BrowserKit              Locale
             ClassLoader        OptionsResolver
                Config               Process
               Console          PropertyAccess
             CssSelector            Routing
             DomCrawler             Security
          DependencyInjection      Serializer
           EventDispatcher        Stopwatch
              Filesystem          Templating
                 Finder           Translation
                 Form              Validator
            HttpFoundation            Yaml
              HttpKernel
Saturday, February 2, 13
Yaml
                     • Easily parse and write YAML files
                     • Implements most of the YAML 1.2 spec
      use SymfonyComponentYamlParser;

      $yaml = new Parser();

      $string = file_get_contents('foo.yml')
      $data = $yaml->parse($string);

      # data, inlining, indenting, invalid types, objects
      $string = $yaml->dump($data, 2, 4, false, true);
      file_put_contents('bar.yml', $string);



Saturday, February 2, 13
Http Foundation
                     • OO API for HTTP Request + Response
                     • OO API for Session incl. “flash messages”
                     • Supports streaming response
       $request = Request::create('/?foo=bar', 'GET');
       echo $request->getPathInfo();

       $resp = JsonResponse::create($data, 200);

       $hdrs = array('Content-Type' => 'text/plain');
       $resp = new StreamingResponse($callback, 404, $hdrs);
       $resp->send();


Saturday, February 2, 13
HTTP Kernel
                     • PHP level CGI interface
                     • Eases integration between Symfony2, Silex,
                           Drupal8, ezPublish5, Laravel4 .. applications
       interface HttpKernelInterface
       {
         const MASTER_REQUEST = 1;
         const SUB_REQUEST = 2;

            public function handle(
               Request $request,
               $type = self::MASTER_REQUEST,
               $catch = true
            );
       }


Saturday, February 2, 13
HTTP Kernel
       use SymfonyComponentHttpFoundationRequest;

       // env: prod, debug: false
       $kernel = new AppKernel('prod', false);

       // wrap the kernel for ESI enabled HTTP caching
       $kernel = new AppCache($kernel);

       // create the request from the super globals
       $request = Request::createFromGlobals();

       // convert request into a response
       $response = $kernel->handle($request);

       // send response content to the client
       $response->send();

       // event fired after browser has received response
       $kernel->terminate($request, $response);




Saturday, February 2, 13
Component usage
            Frameworks / Applications Libraries / Components

                            Drupal 8         Doctrine
                           ezPublish 5         Assetic
                            Laravel 4          Guzzle
                           phpBB 3.5          PHPUnit
                               PPI             Behat
                              Silex            Goutte
                            shopware         Jackalope
                                ..               ..


Saturday, February 2, 13
Symfony2 Framework
                     • HTTP framework 1st , MVC framework 2nd
                     • Very extensible due to event based request
                           processing and dependency injection
                     • Inspired by Django, Spring, Ruby on Rails
                     • HTTP Caching / ESI / Reversed proxy
                     • Extensive documentation + debugging tools
Saturday, February 2, 13
Distributions
                     • Selection of bundles, a default directory / file
                           structure and default configuration
                     • Symfony Standard edition
                            php composer.phar create-project symfony/
                            framework-standard-edition your-dir

                     • Symfony CMF Standard edition
                     • Sonata standard edition
                     • KNP Rad Edition
Saturday, February 2, 13
What is a Bundle?

                 Ideally, the minimal glue code necessary to connect
                 a library with the symfony2 framework (ie. configure
                 the Dependency Injection Container) plus any required
                   controller and routes




Saturday, February 2, 13
Core bundles
                           FrameworkBundle
                            MonologBundle
                             AsseticBundle
                           WebProfilerBundle
                               TwigBundle
                           SwiftmailerBundle
                             SecurityBundle

                                   ..



Saturday, February 2, 13
KNPbundles.com




Saturday, February 2, 13
Popular bundles
                                  FOSUserBundle
                                SonataAdminBundle
                                  FOSRestBundle
                           StofDoctrineExtensionBundle
                                 KnpMenuBundle
                                        ..
                               NelmioApiDocBundle
                               JMSDebuggingBundle
                             LiipCacheControlBundle
                                   KnpRadBundle
                                        ..



Saturday, February 2, 13
The ecosystem
                  Core Dependencies            Popular Dependencies
                               Assetic                  Imagine
                              Monolog          Behat / PHPSpec / Atoum
                           Doctrine / Propel        Buzz / Guzzle
                                 Twig                   Goutte
                             Swiftmailer               KnpMenu
                              PHPUnit               JMS Serializer




Saturday, February 2, 13
Ecosystem




Saturday, February 2, 13
Composer




Saturday, February 2, 13
Composer
                 • Dependency manager for PHP
                 • Based on SUSE Linux dependency resolver
                 curl -s https://getcomposer.org/installer | php
                 php composer.phar install
                 php composer.phar require acme/lib:1.1.* --no-update
                 php composer.phar update acme/lib



                 • Register on packagist.org
                 • Setup your own package index with Satis

Saturday, February 2, 13
Twig




Saturday, February 2, 13
Twig
                     • Template language implemented in PHP
                     • Fast: Compiles to PHP and Javascript
                     • Template inheritance
                     • Secure: sandbox mode, output escaping
                     • Easily create new tags, filters and functions
                     • Many community extensions are available
Saturday, February 2, 13
Twig
       {% extends "base.html" %}

       {% block title %}Index{% endblock %}
       {% block head %}
           {{ parent() }}
           <style type="text/css">
                .important { color: #336699; }
           </style>
       {% endblock %}
       {% block content %}
         {% if users|length > 0 %}
           <ul>
                {% for user in users %}
                    <li>{{ user.username|e }}</li>
                {% endfor %}
           </ul>
       {% endif %}
       {% endblock %}




Saturday, February 2, 13
Assetic
                     • Cleverly handle your JS/CSS web assets
                     • Inspired by the Python webassets lib
                     • Assets : Combine, Less, Sass ...
                     • Filters : Minify,YUICompressor, ..
                     • Provides ways to handle cache busting
                     • Build assets on the fly during development
                           or dump to static files in production

Saturday, February 2, 13
Assetic
       {% stylesheets '@AcmeFooBundle/Resources/public/css/*' %}
           <link rel="stylesheet" href="{{ asset_url }}" />
       {% endstylesheets %}

       {% javascripts 'bundles/acme_foo/js/*' filter='yui_js' %}
           <script src="{{ asset_url }}"></script>
       {% endjavascripts %}

       # Assetic Configuration
       assetic:
         use_controller: false
         #java: /usr/bin/java
         filters:
           cssrewrite: ~
           # closure:
           #      jar: %kernel.root_dir%/java/compiler.jar
           # yui_css:
           #      jar: %kernel.root_dir%/java/yuicompressor-2.4.2.jar



Saturday, February 2, 13
Monolog
                     • PSR-3 compliant logging library
                     • Inspired by the Python logbook lib
                     •     Handlers

                           •   StreamHandler, RotatingFileHandler,
                               NativeMailHandler, MongoDBHandler, ...

                           •   FingersCrossedHandler

                     •     Channels, Formatters, Processors



Saturday, February 2, 13
Monolog
       // create a log channel
       $log = new Logger('name');
       $fileName = 'path/to/your.log';
       $handler = new StreamHandler($fileName, Logger::WARNING);

       // log everything if there is at least one warning or higher
       $log->pushHandler(new FingersCrossedHandler($handler);
       $logger->pushHandler(new FirePHPHandler());

       $socketName = 'unix:///var/log/httpd_app_log.socket';
       $handler = new SocketHandler($socketName);
       $handler->setPersistent(true);
       $logger->pushHandler($handler, Logger::DEBUG);

       // add records to the log
       $log->addWarning('Foo');
       $log->log(Logger::ERROR, 'Bar');




Saturday, February 2, 13
Doctrine
                     • Hibernate inspired data mapper API
                     • ORM Object Relational Mapper (SQL)
                     • Object Document Mapper (CouchDB,
                           MongoDB, PHPCR, OrientDB, ..)
                     • DBAL / Migrations / Fixtures
                     • Annotations, Cache, Inflector, Lexer ..
Saturday, February 2, 13
JMS Serializer
                     • (De)serializing on steroids
                     • Handles nested (recursive) object graphs
                     • Fully leverage XML/JSON/.. features
                     • Exclusion strategies for groups, versioning

                     • Ability to define custom exclusion
                           strategies and events handlers


Saturday, February 2, 13
JMS Serializer
       class BlogPost
       {
         private $title;
         private $content;
         private $date;

       /* @XmlList(inline = true, entry = "tag") */
         private $tags;
         /* @Groups({"admins"})
          * @XmlAttribute
          * @Since("1.1.0") */
         private $version;
         /* @VirtualProperty
          * @SerializedName("slug")
          * @XmlAttribute */
         public function getSlug() { .. }

            ..
       }




Saturday, February 2, 13
JMS Serializer
       // sets the group exclusion strategy
       $serializer->setGroups(array(‘admins’));

       // sets the version exclusion strategy
       // this overrides the group exclusion strategy
       // need to define your own class to combine the two
       $serializer->setVersion(‘1.2.0’);

       $blogPost = new BlogPost($data);
       $serializer->serialize($blogPost, 'json');




Saturday, February 2, 13
Bridges




Saturday, February 2, 13
Bridges

                              TwigBridge
                           SwiftmailerBridge
                            MonologBridge
                            DoctrineBridge
                            Propel1Bridge



Saturday, February 2, 13
Applications




Saturday, February 2, 13
Symfony CMF
                 The Symfony CMF project makes it easier for developers
                 to add CMS functionality to applications built with the
                 Symfony2 framework. Key development principles for the
                 provided sets of bundles are scalability , usability ,
                  documentation and testing .




Saturday, February 2, 13
Symfony CMF
                     • Follows vision of the decoupled CMS on top of
                           Symfony2, PHPCR, Create.js
                     • CMF as target audience are CMS builders:
                           Drupal 8, ezPublish 5, Symfony2 devs, ..
                     • Stable release planned for May 2013
                     • http://cmf.symfony.com
                     • Demo at http://cmf.liip.ch
Saturday, February 2, 13
A decoupled CMS
                     • Decoupled storage, business logic, UI layers
                     • PHPCR is a storage API for CMS, essentially
                           a tree + versioning enabled document DB
                     • Symfony2 handles the business logic
                     • create.js is a glue layer that ties together
                           RDFa, backbone.js, inline edit + JSON-LD


Saturday, February 2, 13
Vespolina Project
                     •      scalable Ecommerce application

                           • from a single person store
                           • to a multi national store.
                     • Decoupled components which can be used
                           independently of Symfony2
                     • Several components will go stable in Q2
                     • http://www.vespolina-project.org
Saturday, February 2, 13
Vespolina Project
              vespolina/vespolinaProductBundle
                           defining managers a DI service




                                      vespolina/vespolinaProduct
                                                   manager & mappings



                                                           vespolina/vespolinaCore
                                                               base classes & interfaces
                                   Framework agnostic


Saturday, February 2, 13
References
                     •     http://fabien.potencier.org/article/49/what-is-symfony2

                     •     http://fabien.potencier.org/article/50/create-your-own-
                           framework-on-top-of-the-symfony2-components-
                           part-1

                     •     http://symfony.com/components

                     •     http://cmf.symfony.com/slides/

                     •     https://speakerdeck.com/hhamon/useful-php-
                           librarieswhy_symfony_cmf.html



Saturday, February 2, 13
Questions?


                              Please rate this talk on

                           http://joind.in/talk/view/8074




Saturday, February 2, 13
Guzzle

                     • HTTP client & framework
                     • Restful web service clients
                     • Used by Amazon AWS SDK, Drupal 8, ...
                     • Uses Symfony Event dispatcher
                     • Service descriptions

Saturday, February 2, 13
Guzzle
       use GuzzleHttpClient;
       $client = new Client('https://api.github.com');

       $request = $client->get('/user')->setAuth('user',
       'pass');
       // Send the request and get the response
       $response = $request->send();




Saturday, February 2, 13
Guzzle
       {
                    "name": "Foo",               Service Description
                    "apiVersion": "2012-10-14",
                    "baseUrl": "http://api.foo.com",
                    "description": "Foo is an API",
                    "operations": {
                        "GetUsers": {
                            "httpMethod": "GET",
                            "uri": "/users",
                            "summary": "Gets a list of users",
                            "responseClass": "GetUsersOutput"
                        },
       ...



Saturday, February 2, 13
Guzzle
       ...
                 "GetUserOutput": {           Service Description
                          "type": "object",
                          "properties": {
                              "name": {
                                  "location": "json",
                                  "type": "string"
                              },
                              "age": {
                                  "location": "json",
                                  "type": "integer"
       ...




Saturday, February 2, 13
Guzzle
       use GuzzleServiceDescriptionServiceDescription;

       $description =
       ServiceDescription::factory('service_description.js
       on');
       $client->setDescription($description);

       $command = $client->getCommand('GetUser',
                   array('id' => 123));
       $responseModel = $client->execute($command);
       echo $responseModel['age'];




Saturday, February 2, 13
Sonata Project
                           • Collection of bundles to quickly create an
                             Admin interface
                           • Media, News, Notification, Formatter,
                             I18N,




Saturday, February 2, 13

Welcome to the Symfony2 World - FOSDEM 2013

  • 1.
    Welcome to the Symfony2 World Lukas Smith Daniel Kucharski @lsmith @inspiran_be Saturday, February 2, 13
  • 2.
    Speakers Lukas Kahwe Smith • Developer at Liip AG in Switzerland • PHP 5.3 co-release-manager, • Contributing to Doctrine, Symfony, PHPCR .. Saturday, February 2, 13
  • 3.
    Speakers Daniel Kucharski • SAP Business Consultant by day • PHP enthusiast at night since 2000 • Co-founder of the Vespolina Ecommerce Project Saturday, February 2, 13
  • 4.
    What is Symfony2? • Symfony2 is a reusable set of standalone, decoupled and cohesive PHP components • Symfony2 is also a full-stack framework • MIT licensed (permissive, GPL compatible) • Compliant with PSR-0 , PSR-1, PSR-2, PSR-3 • https://github.com/symfony/symfony Saturday, February 2, 13
  • 5.
    What is Symfony2? • Approaching 700 contributors • Most popular PHP project on github.com • First stable release in July 2011 • LTS release with 5 year support in May 2013 • Used on many big sites: ted.com, lockerz.com, opensky.com, exercise.com, wetter.de, stern.de .. Saturday, February 2, 13
  • 6.
  • 7.
    BrowserKit Locale ClassLoader OptionsResolver Config Process Console PropertyAccess CssSelector Routing DomCrawler Security DependencyInjection Serializer EventDispatcher Stopwatch Filesystem Templating Finder Translation Form Validator HttpFoundation Yaml HttpKernel Saturday, February 2, 13
  • 8.
    Yaml • Easily parse and write YAML files • Implements most of the YAML 1.2 spec use SymfonyComponentYamlParser; $yaml = new Parser(); $string = file_get_contents('foo.yml') $data = $yaml->parse($string); # data, inlining, indenting, invalid types, objects $string = $yaml->dump($data, 2, 4, false, true); file_put_contents('bar.yml', $string); Saturday, February 2, 13
  • 9.
    Http Foundation • OO API for HTTP Request + Response • OO API for Session incl. “flash messages” • Supports streaming response $request = Request::create('/?foo=bar', 'GET'); echo $request->getPathInfo(); $resp = JsonResponse::create($data, 200); $hdrs = array('Content-Type' => 'text/plain'); $resp = new StreamingResponse($callback, 404, $hdrs); $resp->send(); Saturday, February 2, 13
  • 10.
    HTTP Kernel • PHP level CGI interface • Eases integration between Symfony2, Silex, Drupal8, ezPublish5, Laravel4 .. applications interface HttpKernelInterface { const MASTER_REQUEST = 1; const SUB_REQUEST = 2; public function handle( Request $request, $type = self::MASTER_REQUEST, $catch = true ); } Saturday, February 2, 13
  • 11.
    HTTP Kernel use SymfonyComponentHttpFoundationRequest; // env: prod, debug: false $kernel = new AppKernel('prod', false); // wrap the kernel for ESI enabled HTTP caching $kernel = new AppCache($kernel); // create the request from the super globals $request = Request::createFromGlobals(); // convert request into a response $response = $kernel->handle($request); // send response content to the client $response->send(); // event fired after browser has received response $kernel->terminate($request, $response); Saturday, February 2, 13
  • 12.
    Component usage Frameworks / Applications Libraries / Components Drupal 8 Doctrine ezPublish 5 Assetic Laravel 4 Guzzle phpBB 3.5 PHPUnit PPI Behat Silex Goutte shopware Jackalope .. .. Saturday, February 2, 13
  • 13.
    Symfony2 Framework • HTTP framework 1st , MVC framework 2nd • Very extensible due to event based request processing and dependency injection • Inspired by Django, Spring, Ruby on Rails • HTTP Caching / ESI / Reversed proxy • Extensive documentation + debugging tools Saturday, February 2, 13
  • 14.
    Distributions • Selection of bundles, a default directory / file structure and default configuration • Symfony Standard edition php composer.phar create-project symfony/ framework-standard-edition your-dir • Symfony CMF Standard edition • Sonata standard edition • KNP Rad Edition Saturday, February 2, 13
  • 15.
    What is aBundle? Ideally, the minimal glue code necessary to connect a library with the symfony2 framework (ie. configure the Dependency Injection Container) plus any required controller and routes Saturday, February 2, 13
  • 16.
    Core bundles FrameworkBundle MonologBundle AsseticBundle WebProfilerBundle TwigBundle SwiftmailerBundle SecurityBundle .. Saturday, February 2, 13
  • 17.
  • 18.
    Popular bundles FOSUserBundle SonataAdminBundle FOSRestBundle StofDoctrineExtensionBundle KnpMenuBundle .. NelmioApiDocBundle JMSDebuggingBundle LiipCacheControlBundle KnpRadBundle .. Saturday, February 2, 13
  • 19.
    The ecosystem Core Dependencies Popular Dependencies Assetic Imagine Monolog Behat / PHPSpec / Atoum Doctrine / Propel Buzz / Guzzle Twig Goutte Swiftmailer KnpMenu PHPUnit JMS Serializer Saturday, February 2, 13
  • 20.
  • 21.
  • 22.
    Composer • Dependency manager for PHP • Based on SUSE Linux dependency resolver curl -s https://getcomposer.org/installer | php php composer.phar install php composer.phar require acme/lib:1.1.* --no-update php composer.phar update acme/lib • Register on packagist.org • Setup your own package index with Satis Saturday, February 2, 13
  • 23.
  • 24.
    Twig • Template language implemented in PHP • Fast: Compiles to PHP and Javascript • Template inheritance • Secure: sandbox mode, output escaping • Easily create new tags, filters and functions • Many community extensions are available Saturday, February 2, 13
  • 25.
    Twig {% extends "base.html" %} {% block title %}Index{% endblock %} {% block head %} {{ parent() }} <style type="text/css"> .important { color: #336699; } </style> {% endblock %} {% block content %} {% if users|length > 0 %} <ul> {% for user in users %} <li>{{ user.username|e }}</li> {% endfor %} </ul> {% endif %} {% endblock %} Saturday, February 2, 13
  • 26.
    Assetic • Cleverly handle your JS/CSS web assets • Inspired by the Python webassets lib • Assets : Combine, Less, Sass ... • Filters : Minify,YUICompressor, .. • Provides ways to handle cache busting • Build assets on the fly during development or dump to static files in production Saturday, February 2, 13
  • 27.
    Assetic {% stylesheets '@AcmeFooBundle/Resources/public/css/*' %} <link rel="stylesheet" href="{{ asset_url }}" /> {% endstylesheets %} {% javascripts 'bundles/acme_foo/js/*' filter='yui_js' %} <script src="{{ asset_url }}"></script> {% endjavascripts %} # Assetic Configuration assetic: use_controller: false #java: /usr/bin/java filters: cssrewrite: ~ # closure: # jar: %kernel.root_dir%/java/compiler.jar # yui_css: # jar: %kernel.root_dir%/java/yuicompressor-2.4.2.jar Saturday, February 2, 13
  • 28.
    Monolog • PSR-3 compliant logging library • Inspired by the Python logbook lib • Handlers • StreamHandler, RotatingFileHandler, NativeMailHandler, MongoDBHandler, ... • FingersCrossedHandler • Channels, Formatters, Processors Saturday, February 2, 13
  • 29.
    Monolog // create a log channel $log = new Logger('name'); $fileName = 'path/to/your.log'; $handler = new StreamHandler($fileName, Logger::WARNING); // log everything if there is at least one warning or higher $log->pushHandler(new FingersCrossedHandler($handler); $logger->pushHandler(new FirePHPHandler()); $socketName = 'unix:///var/log/httpd_app_log.socket'; $handler = new SocketHandler($socketName); $handler->setPersistent(true); $logger->pushHandler($handler, Logger::DEBUG); // add records to the log $log->addWarning('Foo'); $log->log(Logger::ERROR, 'Bar'); Saturday, February 2, 13
  • 30.
    Doctrine • Hibernate inspired data mapper API • ORM Object Relational Mapper (SQL) • Object Document Mapper (CouchDB, MongoDB, PHPCR, OrientDB, ..) • DBAL / Migrations / Fixtures • Annotations, Cache, Inflector, Lexer .. Saturday, February 2, 13
  • 31.
    JMS Serializer • (De)serializing on steroids • Handles nested (recursive) object graphs • Fully leverage XML/JSON/.. features • Exclusion strategies for groups, versioning • Ability to define custom exclusion strategies and events handlers Saturday, February 2, 13
  • 32.
    JMS Serializer class BlogPost { private $title; private $content; private $date; /* @XmlList(inline = true, entry = "tag") */ private $tags; /* @Groups({"admins"}) * @XmlAttribute * @Since("1.1.0") */ private $version; /* @VirtualProperty * @SerializedName("slug") * @XmlAttribute */ public function getSlug() { .. } .. } Saturday, February 2, 13
  • 33.
    JMS Serializer // sets the group exclusion strategy $serializer->setGroups(array(‘admins’)); // sets the version exclusion strategy // this overrides the group exclusion strategy // need to define your own class to combine the two $serializer->setVersion(‘1.2.0’); $blogPost = new BlogPost($data); $serializer->serialize($blogPost, 'json'); Saturday, February 2, 13
  • 34.
  • 35.
    Bridges TwigBridge SwiftmailerBridge MonologBridge DoctrineBridge Propel1Bridge Saturday, February 2, 13
  • 36.
  • 37.
    Symfony CMF The Symfony CMF project makes it easier for developers to add CMS functionality to applications built with the Symfony2 framework. Key development principles for the provided sets of bundles are scalability , usability , documentation and testing . Saturday, February 2, 13
  • 38.
    Symfony CMF • Follows vision of the decoupled CMS on top of Symfony2, PHPCR, Create.js • CMF as target audience are CMS builders: Drupal 8, ezPublish 5, Symfony2 devs, .. • Stable release planned for May 2013 • http://cmf.symfony.com • Demo at http://cmf.liip.ch Saturday, February 2, 13
  • 39.
    A decoupled CMS • Decoupled storage, business logic, UI layers • PHPCR is a storage API for CMS, essentially a tree + versioning enabled document DB • Symfony2 handles the business logic • create.js is a glue layer that ties together RDFa, backbone.js, inline edit + JSON-LD Saturday, February 2, 13
  • 40.
    Vespolina Project • scalable Ecommerce application • from a single person store • to a multi national store. • Decoupled components which can be used independently of Symfony2 • Several components will go stable in Q2 • http://www.vespolina-project.org Saturday, February 2, 13
  • 41.
    Vespolina Project vespolina/vespolinaProductBundle defining managers a DI service vespolina/vespolinaProduct manager & mappings vespolina/vespolinaCore base classes & interfaces Framework agnostic Saturday, February 2, 13
  • 42.
    References • http://fabien.potencier.org/article/49/what-is-symfony2 • http://fabien.potencier.org/article/50/create-your-own- framework-on-top-of-the-symfony2-components- part-1 • http://symfony.com/components • http://cmf.symfony.com/slides/ • https://speakerdeck.com/hhamon/useful-php- librarieswhy_symfony_cmf.html Saturday, February 2, 13
  • 43.
    Questions? Please rate this talk on http://joind.in/talk/view/8074 Saturday, February 2, 13
  • 44.
    Guzzle • HTTP client & framework • Restful web service clients • Used by Amazon AWS SDK, Drupal 8, ... • Uses Symfony Event dispatcher • Service descriptions Saturday, February 2, 13
  • 45.
    Guzzle use GuzzleHttpClient; $client = new Client('https://api.github.com'); $request = $client->get('/user')->setAuth('user', 'pass'); // Send the request and get the response $response = $request->send(); Saturday, February 2, 13
  • 46.
    Guzzle { "name": "Foo", Service Description "apiVersion": "2012-10-14", "baseUrl": "http://api.foo.com", "description": "Foo is an API", "operations": { "GetUsers": { "httpMethod": "GET", "uri": "/users", "summary": "Gets a list of users", "responseClass": "GetUsersOutput" }, ... Saturday, February 2, 13
  • 47.
    Guzzle ... "GetUserOutput": { Service Description "type": "object", "properties": { "name": { "location": "json", "type": "string" }, "age": { "location": "json", "type": "integer" ... Saturday, February 2, 13
  • 48.
    Guzzle use GuzzleServiceDescriptionServiceDescription; $description = ServiceDescription::factory('service_description.js on'); $client->setDescription($description); $command = $client->getCommand('GetUser', array('id' => 123)); $responseModel = $client->execute($command); echo $responseModel['age']; Saturday, February 2, 13
  • 49.
    Sonata Project • Collection of bundles to quickly create an Admin interface • Media, News, Notification, Formatter, I18N, Saturday, February 2, 13