hands-on with the symfony2 framework
DESCRIPTION
Symfony2: What's all the buzz about?Follow along as we download, install and get a hands-on experience using Symfony2. This presentation shows you how to get started with Symfony and introduces you to the large group of new PHP libraries coming from the Symfony2 community. You'll see examples of how to create pages, use template inheritance, and create a simple JSON API.TRANSCRIPT
![Page 1: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/1.jpg)
Hands on with Symfony2
Ryan Weaver@weaverryan
![Page 2: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/2.jpg)
Who is this dude?
• Co-author of the Symfony2 Docs
• Core Symfony2 contributor
• Founder of KnpLabs US
• Geek, running, Nashville
http://www.twitter.com/weaverryanhttp://www.github.com/weaverryan
![Page 3: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/3.jpg)
iostudio
• Advertising & Integrated Marketing Solutions
• A great, growing Nashville tech company
• Hiring good developers (of all backgrounds) to be part of a dynamic, fun team
http://iostudio.com/careers
![Page 4: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/4.jpg)
Quality. Innovation. Excitement.
• Your symfony/Symfony2 development experts
• Consulting & application auditing
• Symfony2 Training
• Behind lots of open source initiatives
KnpLabs
![Page 5: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/5.jpg)
• Right here in Nashville: May 19th & 20th
• real coding, real project• Doctrine2, forms, security, caching, etc• Cool libraries like Assetic, Imagine, Behat• Lot’s more
• Or join us in New York City: June 6th & 7th
Symfony2 Training
http://bit.ly/symfony-training
![Page 6: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/6.jpg)
Act 1:
Meet Symfony
![Page 7: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/7.jpg)
Symfony is a PHP Framework, a Philosophy, and
a Community - all working together in harmony.
symfony.com/what-is-symfony
What is Symfony2?
![Page 8: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/8.jpg)
• A group of standalone PHP components
• Bundled into a full-service framework
Symfony2
Solves your difficult, redundant problems
... and then stays the hell out of the way
![Page 9: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/9.jpg)
• Data persistence(via Doctrine)
• Security• Forms• Validation• Templating• Autoloading• Logging
Problems Solved
• Asset Management• Routing• File+Dir Traversing• Translation• Dependency Injection• Image Manipulation• Console Tasks• Caching
![Page 10: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/10.jpg)
Act 2:
Why Symfony2?
![Page 11: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/11.jpg)
By way of comparison, Symfony 2.0 is about 3 times faster than Version 1.4 or than Zend Framework 1.10,
while taking up 2 times less memory.
http://symfony.com/six-good-technical-reasons
Symfony2 is fast
![Page 12: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/12.jpg)
“Symfony2 is an extremely full featured, modular, and
crazy fast framework.”
spf13.com/post/symfony2
Steve FranciaVice President of Engineering at OpenSky
Symfony2 is full-featured
![Page 13: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/13.jpg)
“Symfony2 is probably one of the most flexible PHP frameworks ever
created. You can literally change everything.”
~ Blog.NewITFarmer.com
Infinitely Flexible Architecture
http://bit.ly/symfony-new-it-farmer
![Page 14: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/14.jpg)
A huge community of developers
• 167 core contributors
• 87 documentation contributors
... and counting ...
![Page 15: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/15.jpg)
A huge eco-system of open source libraries
• 223 open source Symfony2 bundles
• 74 open source Symfony2 projects
... and counting ...
![Page 16: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/16.jpg)
Symfony2Bundles.org
• 223 open source bundles• 74 open source projects
http://symfony2bundles.org/
![Page 17: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/17.jpg)
• One of the most popular PHP frameworks in the world
• First released in October 2005
• Nearly 100 releases
• Powers a lot of big sites
nationalguard.com, dailymotion.com, exercise.com, shopopensky.com, etc
Proven Reputation
![Page 18: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/18.jpg)
Act 3:
Dive into Symfony
![Page 19: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/19.jpg)
• Symfony offers “distributions” (think Ubuntu)
• The “Standard Distribution” comes with everything you’ll need + some bonuses
• Fully-functional application• Intelligent default configuration• Some demo pages we can play with
The “Standard Distribution”
![Page 21: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/21.jpg)
Step 2: Unzip it!
$ cd /path/to/webroot
$ tar zxvf /path/to/Symfony_Standard_Vendors_2.0.0PR11.tgz
![Page 22: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/22.jpg)
Step 3: Run it!
http://localhost/Symfony/web/config.php
![Page 23: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/23.jpg)
•Fix any major problems (e.g. missing libraries, permissions issues) that Symfony reports
• Then click “Configure your Symfony Application online”
Tend to your Garden
![Page 24: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/24.jpg)
Step 3: Configure it!
Optional: but a nice interface to get you started
quickly
![Page 25: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/25.jpg)
Finished!
This *is* your first Symfony2
page
![Page 26: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/26.jpg)
Act 4:
Let’s create some pages
![Page 27: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/27.jpg)
The 3 Steps to a Page
Step1: Symfony matches the URL to a route
Step2: Symfony executes the controller (a PHP function) of the route
Step3: The controller (your code) returns a Symfony Response object
/hello/ryan
<h1>Hello ryan!</h1>
![Page 28: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/28.jpg)
• Our goal: to create a hello world-like app
• ... and then to make it do all sorts of interesting things ...
remove half the code, JSON version, security, caching...
Hello {insert-name}!
![Page 29: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/29.jpg)
Step1: Symfony matches the URL to a route
_welcome: pattern: / defaults: { _controller: AcmeDemoBundle:Welcome:index }/
You define the routes (URLs) of your app
/hello/ryanhello_demo: pattern: /hello/{name} defaults: { _controller: AcmeDemoBundle:Meetup:hello }
![Page 30: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/30.jpg)
Homework
Add the following route toapp/config/routing.yml
** Routes can also be defined in XML, PHP and as annotations
hello_demo: pattern: /hello/{name} defaults: { _controller: AcmeDemoBundle:Meetup:hello }
![Page 31: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/31.jpg)
hello_demo: pattern: /hello/{name} defaults: { _controller: AcmeDemoBundle:Meetup:hello }
Step2: Symfony executes the controller of the route
Controller Class::method()
Acme\DemoBundle\Controller\MeetupController::helloAction()
Symfony will execute this PHP method
![Page 32: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/32.jpg)
HomeworkCreate the controller class:
<?php// src/Acme/DemoBundle/Controller/MeetupController.phpnamespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;use Symfony\Component\HttpFoundation\Response;
class MeetupController extends Controller{ public function helloAction($name) { return new Response('Hello '.$name); }}
![Page 33: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/33.jpg)
use Symfony\Component\HttpFoundation\Response;
public function helloAction($name){ return new Response('Hello '.$name);}
Step 3: The Controller returns a Symfony Response object
This is the only requirement of a controller
![Page 34: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/34.jpg)
use Symfony\Component\HttpFoundation\Response;
public function helloAction($name){ return new Response('Hello '.$name);}
Routing Placeholders
hello_demo: pattern: /hello/{name} defaults: { _controller: AcmeDemoBundle:Meetup:hello }
The route matches URLs like /hello/*
And gives you access to the {name} value
![Page 35: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/35.jpg)
It’s Alive!
http://localhost/Symfony/web/app_dev.php/hello/ryan
![Page 36: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/36.jpg)
Rendering a Template
• A template is a tool that you may choose to use
• A template is used to generate “presentation” code (e.g. HTML)
• Keep your pretty (<div>) code away from your nerdy ($foo->sendEmail($body)) code
![Page 37: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/37.jpg)
HomeworkRender a template in the controller
public function helloAction($name){ $response = $this->render( 'AcmeDemoBundle:Meetup:hello.html.twig', array('name' => $name) ); return $response;}
![Page 38: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/38.jpg)
HomeworkCreate the template file
{# src/Acme/DemoBundle/Resources/views/Meetup/hello.html.twig #}
Hello {{ name }}
This is Twig
Twig is a fast, secure and powerful templating engine
We *LOVE* Twig... but
Symfony2 fully supports Twig and regularPHP templates
![Page 39: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/39.jpg)
It’s Still Alive!
http://localhost/Symfony/web/app_dev.php/hello/ryan
![Page 40: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/40.jpg)
Dress that Template
• All pages share common elements (header, footer, sidebar, etc)
• We think about the problem differently: a template can be decorated by another
![Page 41: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/41.jpg)
template inheritance allows you to build a base "layout" template that contains all the common elements of your site and defines "blocks" that child templates can override
![Page 42: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/42.jpg)
header
sidebar content
A base layout file defines “blocks”
Each block can have a default value
{% block header %} <h1>Welcome!</h1>{% endblock %}
![Page 43: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/43.jpg)
header
sidebar contentand “overrides” the parent’s blocks
The child template “extends” the parent
{% block header %} <h1>Super hello Welcome!</h1>{% endblock %}
![Page 44: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/44.jpg)
HomeworkMake the template extend a base template
{# src/Acme/DemoBundle/Resources/views/Meetup/hello.html.twig #}{% extends "AcmeDemoBundle::layout.html.twig" %}
{% block title "Hello " ~ name %}
{% block content %} <h1>Hello {{ name }}!</h1>{% endblock %}
layout: src/Acme/DemoBundle/Resources/views/layout.html.twig
![Page 45: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/45.jpg)
It’s Beautiful!
http://localhost/Symfony/web/app_dev.php/hello/ryan
![Page 46: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/46.jpg)
Act 5:
Remove all the code
![Page 47: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/47.jpg)
Do Less Work
• So far, we have:• a route• a controller• a template
• We can do all of this with even less code
![Page 48: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/48.jpg)
Homework
Change yourapp/config/routing.yml
This now imports routing information from our controller
hello_demo: resource: "@AcmeDemoBundle/Controller/MeetupController.php" type: annotation
![Page 49: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/49.jpg)
Homework
Add the route to your controller /** * @extra:Route("/hello/{name}", name="hello_demo") */ public function helloAction($name) { $response = $this->render( 'AcmeDemoBundle:Meetup:hello.html.twig', array('name' => $name) ); return $response; }
The PHP comments are called “annotations”
Symfony can use annotations to read routing config
Your route and controller are in the same place!
![Page 50: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/50.jpg)
Annotations /** * @extra:Route("/hello/{name}", name="hello_demo") */ public function helloAction($name) { $response = $this->render( 'AcmeDemoBundle:Meetup:hello.html.twig', array('name' => $name) ); return $response; }
The PHP comments are
called “annotations”
Symfony can use annotations to read routing configYour route and controller are in the same place!
![Page 51: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/51.jpg)
Remove more code
Instead of rendering the template, tell Symfony to do it for you /** * @extra:Route("/hello/{name}", name="hello_demo") * @extra:Template() */ public function helloAction($name) { return array('name' => $name); }
![Page 52: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/52.jpg)
/** * @extra:Route("/hello/{name}", name="hello_demo") * @extra:Template() */ public function helloAction($name) { return array('name' => $name); }
Controller: AcmeDemoBundle:Meetup:hello
Template: AcmeDemoBundle:Meetup:hello.html.twig
![Page 53: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/53.jpg)
Now with less code!
http://localhost/Symfony/web/app_dev.php/hello/ryan
![Page 54: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/54.jpg)
Act 6:
JSON { name: “Ryan” }
![Page 55: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/55.jpg)
Create a JSON API
• We have an HTML version of our page
• How about a JSON version?
![Page 56: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/56.jpg)
Add a _format to the route/** * @extra:Route("/hello/{name}.{_format}", defaults={"_format"="html"}) * @extra:Template() */public function helloAction($name){ return array('name' => $name);}
“/hello/ryan” still works exactly as before
![Page 57: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/57.jpg)
Create a JSON template
“/hello/ryan.json” renders a JSON array
{# src/Acme/DemoBundle/Resources/views/Meetup/hello.json.twig #}
{% set arr = { 'name': name } %}
{{ arr | json_encode | raw }}
{"name":"ryan"}
It’s that simple
![Page 58: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/58.jpg)
To review
• Symfony looks for the value of the special “_format” routing placeholder
• The _format is used in the name of the template (hello.json.twig)
• Symfony also returns the proper Content-Type (application/json)
![Page 59: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/59.jpg)
RestBundle
• For a truly robust solution to RESTful API’s, see the community-driven RestBundle
https://github.com/FriendsOfSymfony/RestBundle
![Page 60: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/60.jpg)
Act 7:
With annotations, you can
![Page 61: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/61.jpg)
Add security
/** * @extra:Route("/hello/admin/{name}") * @extra:Secure(roles="ROLE_ADMIN") * @extra:Template() */public function helloadminAction($name){ return array('name' => $name);}
![Page 62: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/62.jpg)
Add caching
/** * @extra:Route("/hello/{name}.{_format}", defaults={"_format"="html"}) * @extra:Template() * @extra:Cache(maxage="86400") */public function helloAction($name){ return array('name' => $name);}
![Page 63: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/63.jpg)
Act 8:
PHP Libraries by theSymfony Community
![Page 64: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/64.jpg)
Doctrine2http://www.doctrine-project.org/
• Database Abstraction Library (DBAL)
• Object Relational Mapper (ORM)
• Object Document Mapper (ODM)--> (for Mongo DB)
Doctrine persists data better than anyone
![Page 65: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/65.jpg)
Assetic
• PHP asset management framework
• Run CSS and JS through filters• LESS, SASS and others• Compress the assets
• Compile CSS and JS into a single file each
https://github.com/kriswallsmith/assetic
![Page 66: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/66.jpg)
Behat + Mink
• Behavioral-driven development framework
http://behat.org/
• Write human-readable sentences that test your code (and can be run in a browser)
![Page 67: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/67.jpg)
Gaufrette
• PHP filesystem abstraction library
• Read and write from Amazon S3 or FTP like a local filesystem
https://github.com/knplabs/Gaufrette
// ... setup your filesystem
$content = $filesystem->read('myFile');$content = 'Hello I am the new content';
$filesystem->write('myFile', $content);
![Page 68: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/68.jpg)
Imagine
• PHP Image manipulation library
• Does crazy things and has crazy docs
use Imagine\Image\Box;use Imagine\Image\Point;
$image->resize(new Box(15, 25)) ->rotate(45) ->crop(new Point(0, 0), new Box(45, 45)) ->save('/path/to/new/image.jpg');
https://github.com/avalanche123/Imagine
![Page 69: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/69.jpg)
Silex
• Microframework built from Symfony2 Components
require_once __DIR__.'/silex.phar';
$app = new Silex\Application();
$app->get('/hello/{name}', function($name) { return "Hello $name"; });
$app->run();
http://silex-project.org/
• That’s your whole app :)
![Page 70: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/70.jpg)
Sonata Admin Bundle
• Admin generator for Symfony2
https://github.com/sonata-project/AdminBundle
![Page 71: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/71.jpg)
Act 9:
Last words
![Page 72: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/72.jpg)
Symfony2 is...
• Fast as hell• Infinitely flexible• Fully-featured• Driven by a huge community
• Not released yet...Release candidate coming very soon...
![Page 73: Hands-on with the Symfony2 Framework](https://reader034.vdocuments.us/reader034/viewer/2022052310/5549b5cdb4c905bc6d8b4b79/html5/thumbnails/73.jpg)
Thanks!
Ryan Weaver@weaverryan
Questions?
Symfony2 Trainingin Nashville
Join us May 19th & 20th