Practical Guided Tour of Symfony

Similar documents
Symfony2 and Drupal. Why to talk about Symfony2 framework?

A Tour of Silex and Symfony Components. Robert

Drupal 8. Core and API Changes Shabir Ahmad MS Software Engg. NUST Principal Software Engineser PHP/Drupal

Symfony 2 Tutorial. Model. Neues Bundle erstellen: php app/console generate:bundle --namespace=blogger/blogbundle

The Best Practices Book Version: 2.5

Saturday, June 16, 12. Introducing

Drupal 8 The site builder's release

The Components Book Version: master

Web Development with Flask and the Raspberry Pi Leading by Example CUAUHTEMOC CARBAJAL ITESM CEM 22/04/2014

Symfony2: estudo de caso IngressoPrático

Varnish the Drupal way

How To Create A Simple Module in Magento 2.0. A publication of

Creating a Drupal 8 theme from scratch

What s really under the hood? How I learned to stop worrying and love Magento

The Book for Symfony 2.0

.NET Best Practices Part 1 Master Pages Setup. Version 2.0

The Book. Prepared by the core team, this is the Symfony bible. It is the reference for any user of the platform,

EZ PLATFORM DESIGN AND DEVELOP CONTENT-DRIVEN WEBSITES AND APPLICATIONS

Agile Web Development Liip.ch. Introduction to. Lukas Kahwe some content graciously stolen from Yoav

database abstraction layer database abstraction layers in PHP Lukas Smith BackendMedia

Chris van Daele / / QuestBack, Köln. Laravel 5 Framework. The PHP Framework for Web Artisans

symfony symfony as a platform Fabien Potencier

Documentum Developer Program

Outline. Lecture 18: Ruby on Rails MVC. Introduction to Rails

<link rel="stylesheet" type="text/css" media="all" href="css/iphone.css" /> <!-- User defined styles -->

Modern Web Application Framework Python, SQL Alchemy, Jinja2 & Flask

NoSQL web apps. w/ MongoDB, Node.js, AngularJS. Dr. Gerd Jungbluth, NoSQL UG Cologne,

Easy configuration of NETCONF devices

Introduction to Tizen SDK Alpha. Taiho Choi Samsung Electronics

Secure Testing Service

Sightly Component Development

Mink Documentation. Release 1.6. Konstantin Kudryashov (everzet)

About ZPanel. About the framework. The purpose of this guide. Page 1. Author: Bobby Allen Version: 1.1

Application layer Web 2.0

(An) Optimal Drupal 7 Module Configuration for Site Performance JOE PRICE

ASP.NET Using C# (VS2012)

Bubble Full Page Cache for Magento

Cache All The Things

Server Architecture for High- Performance Drupal

Magento Test Automation Framework User's Guide

Agenda. 1. ZAPms Konzept. 2. Benutzer-Kontroller. 3. Laout-Aufbau. 4. Template-Aufbau. 6. Konfiguration. 7. Module.

Everything you ever wanted to know about Drupal 8*

Testing on the Edge Sebastian Bergmann October 28th 2013

The Symfony CMF Book Version: master

Links Getting Started with Widgets, Gadgets and Mobile Apps

Expert PHP and MySQL. Application Desscpi and Development. Apress" Marc Rochkind

Entites in Drupal 8. Sascha Grossenbacher Christophe Galli

Web Design Course. Home Page. Join in. Home. Objectives. Course Content. Assignments & Discussion. Grades. Help. Contact Me aab43@uakron.

Learning To Fly: How Angry Birds Reached the Heights of Store Performance

Hello friends, This is Aaditya Purani and i will show you how to Bypass PHP LFI(Local File Inclusion)

Layers of Caching: Key to scaling your website. Lance Albertson -- Narayan Newton

Björn Kraus. Session Aware Full Page Caching For Magento With Varnish ESI

Software Development & Education Center PHP 5

Modern Web Development From Angle Brackets to Web Sockets

Faichi Solutions. The Changing Face of Drupal with Drupal 8

Drupal 8 Theming. Exploring Twig & Other Frontend Changes CROWD. Communications Group, LLC CROWD. Communications Group, LLC

Drupal High Availability High Performance

Ansible. Configuration management tool and ad hoc solution. Marcel Nijenhof

Amplify Service Integration Developer Productivity with Oracle SOA Suite 12c

Penetration Testing with Selenium. OWASP 14 January The OWASP Foundation

BI xpress Product Overview


Accelerating Zope applications with Squid and ESI

Mojolicious. Marcos Rebelo

Expert PHP 5 Tools. Proven enterprise development tools and best practices for designing, coding, testing, and deploying PHP applications.

A Tool for Evaluation and Optimization of Web Application Performance

What s New in IBM Web Experience Factory IBM Corporation

Introducing Apache Pivot. Greg Brown, Todd Volkert 6/10/2010

PHP and XML. Brian J. Stafford, Mark McIntyre and Fraser Gallop

Building Rich Internet Applications with PHP and Zend Framework

Volkov Vyacheslav. Summary. Saransk, , Mordovia, Russian Federation Moscow, Russian Federation +7(925)

Hypertext for Hyper Techs

CERTIFIED MULESOFT DEVELOPER EXAM. Preparation Guide

Advanced Web Development SCOPE OF WEB DEVELOPMENT INDUSTRY

JAVA WEB START OVERVIEW

Benchmarking filesystems and PostgreSQL shared buffers

Para perfeccionistas con deadlines

Owner of the content within this article is Written by Marc Grote

Introduction to Web Development

Application Servers G Session 2 - Main Theme Page-Based Application Servers. Dr. Jean-Claude Franchitti

WA 2. GWT Martin Klíma

Metadata in Translation Tools: Importance, Usage, Storage, Transfer. Angelika Zerfaß & Richard Sikes

Drupal CMS for marketing sites

Transcription:

Practical Guided Tour of Symfony

Standalone Components

DependencyInjection EventDispatcher HttpFoundation DomCrawler ClassLoader BrowserKit CssSelector Filesystem HttpKernel Templating Translation Serializer Validator Console Process Routing Security Config Finder Locale Form Yaml

Full Stack Layer

Application bundles Third party bundles The Symfony2 stack Core Bundles Third party libraries Bridges Standalone Components

Bundles

What makes Symfony2 unique?

- PHP 5.3 - RFC2616 - PHPUnit - CI Ready - Jinja Templates - Design Patterns

Easy Installation http://symfony.com/download

Standard Edition Distribution

Want to give it a try?

Philosophy

class DefaultController extends Controller { /** * @Route("/hello/{name}") */ public function indexaction($name) { //... do things } } return new Response(sprintf('Hello %s!', $name));

class DefaultController extends Controller { /** * @Route("/hello/{name}") */ public function indexaction($name) { //... do things } } return $this->render( 'SensioHelloBundle:Default:index.html.twig', array('name' => $name) );

class DefaultController extends Controller { /** * @Route("/schedule") * @Template() */ public function indexaction() { $title = 'Conferences Schedule'; } } return array('title' => $title);

{% extends "SensioConferenceBundle::layout.html.twig" %} {% block content %} <h1> {{ title }} </h1> <ul> <li>http Caching, by Fabien Potencier</li> <li>hiphop for PHP, by Scott Mac Vicar</li> <li>xdebug, by Derick Rethans</li> <li>...</li> </ul> {% endblock %}

Twig is a modern template engine for PHP Fast Concise and rich syntax Automatic output escaping Modern features Extensible Flexible

{% extends "SensioConferenceBundle::layout.html.twig" %} {% block content %} <h1> {{ title }} </h1> <ul> <li>http Caching, by Fabien Potencier</li> <li>hiphop for PHP, by Scott Mac Vicar</li> <li>xdebug, by Derick Rethans</li> <li>...</li> </ul> {% endblock %}

{% extends "::base.html.twig" %} {% block body %} <img src="/images/logo.gif" alt="confoo 2011"/> {% block content %}{% endblock %} {% endblock %}

<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title> {% block title %}Welcome!{% endblock %} </title> <link rel="shortcut icon" href="{{ asset('favicon.ico') }}" /> </head> <body> {% block body %}{% endblock %} </body> </html>

base.html.twig layout.html.twig index.html.twig

Routing System

/** * @Route( * "/{year}/talk/{month}/{day}/{slug}", * requirements={ * "year"="\d{4}", * "month"="\d{2}", * "day"="\d{2}" * } * ) * @Template() */ public function showaction($slug, $day, $month, $year) { //... }

/** * @Route("/talk/{id}") * @ParamConverter("talk", class="sensioconfbundle:talk") * @Template() */ public function showaction(talk $talk) { return array('talk' => $talk); }

Easy Debugging h"p://www.flickr.com/photos/artelaphe/

CODING STANDARDS

IDEs INTEGRATION

THE PROFILER

DEBUGGING TOOLS

h"p://www.flickr.com/photos/chanceprojects/

Doctrine2 Support Database Abstraction Layer on top of PDO Object Relational Mapper Migrations support Object Document Mapper (MongoDB) Object XML Mapper (XML databases)

/** * @ORM\Entity() */ class Talk { /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** @ORM\Column(length=80) */ private $title; /** @ORM\Column(type="text") */ private $synopsis; /** @ORM\Column(type="datetime") */ private $schedule; } /** @ORM\ManyToMany(targetEntity="Speaker", mappedby="talks") */ private $speakers;

Validation

class Task { private $name; private $duedate; public function getname() { return $this->name; } public function setname($name) { $this->name = $name; } public function getduedate() { return $this->duedate; } } public function setduedate(\datetime $duedate = null) { $this->duedate = $duedate; }

class Task { /** * @Assert\NotBlank() * @Assert\MinLength(5) * @Assert\MaxLength(30) */ private $name; /** * @Assert\NotBlank() * @Assert\Type() * @Assert\MaxLength(30) */ private $duedate; } //...

Forms Management h"p://www.flickr.com/photos/miahz/

namespace Sensio\Bundle\TodoBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilder; class TaskType extends AbstractType { public function buildform(formbuilder $builder, array $options) { $builder->add('name'); $builder->add('duedate', 'date'); } } public function getname() { return 'task'; }

public function newaction() { $task = new Task(); $task->setname('write a blog post'); $task->setduedate(new \DateTime('tomorrow')); $request = $this->getrequest(); $form = $this->createform(new TaskType(), $task); if ($request->getmethod() == 'POST') { $form->bindrequest($request); if ($form->isvalid()) { // save the task to the database... } } } return $this->redirect($this->generateurl('success'));

{% extends 'SensioTodoBundle::layout.html.twig' %} {% block content %} <form action="#" method="post"> {{ form_widget(form) }} <input type="submit" value="send!" /> </form> {% endblock %}

Automated Testing h"p://www.flickr.com/photos/kenstein/

UNIT TESTING

FUNCTIONAL TESTING

HTTP Compliance (RFC2616)

Expiration vs Validation

class DefaultController extends Controller { /** * @Route("/schedule") * @Template * @Cache(expires="tomorrow") */ public function indexaction() { $title = 'Conferences Schedule'; } } return array('title' => $title);

class DefaultController extends Controller { /** * @Route("/schedule") * @Template * @Cache(maxage="20") */ public function indexaction() { $title = 'Conferences Schedule'; } } return array('title' => $title);

PHP Reverse Proxy

Varnish Squid

http://varnish-cache.org

Edge Side Includes <esi:include src="http://..." />

No ESI

With ESI <esi:include />

Code Generation

$ php app/console generate:bundle

$ php app/console generate:doctrine:crud

h"p://www.flickr.com/photos/bwop/

<?xml version="1.0"?> <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> <file source-language="en" datatype="plaintext" original="file.ext"> <body> <trans-unit id="1"> <source>symfony2 is great</source> <target>j'aime Symfony2</target> </trans-unit> </body> </file> </xliff>

{% set message = 'Symfony2 is great' %} {{ message trans }} {% set message = 'My name is %name%!' %} {{ message trans({'%name%': 'Hugo'}, "hello") }}

h"p://www.flickr.com/photos/cstein96/

Roadmap for 2.1? h"p://www.flickr.com/photos/mkrigsman/

Thank You!