symony2 a next generation php framework

Download Symony2 A Next Generation PHP Framework

Post on 27-Jan-2015

105 views

Category:

Technology

3 download

Embed Size (px)

DESCRIPTION

A mixture of architecture and hands-on examples, this presentation takes you through the killer features of Symfony2, how it's so decoupled, and how you can get started developing in it.As an added bonus, a number of new standalone PHP libraries and tools are mentioned at the end.

TRANSCRIPT

  • 1. Symfony2 The Next Generation PHP FrameworkRyan Weaver@weaverryanThursday, May 12, 2011

2. Who is this dude? Co-author of the Symfony2 Docs Core Symfony2 contributor Founder of KnpLabs US Boyfriend of the much more talented @leannapelhamhttp://www.knplabs.com/enhttp://www.github.com/weaverryanThursday, May 12, 2011 3. KnpLabs Quality. Innovation. Excitement. Your symfony/Symfony2 development experts Active in a ton of open source initiatives Consulting, application auditing and training http://bit.ly/symfony-trainingThursday, May 12, 2011 4. Act 1: What is Symphony? Symfony!Thursday, May 12, 2011 5. A Bunch of Standalone Libs Routing HttpFoundationDoctrine2 DBALSecurityDependencyInjection EventDispatcher Assetic Translation Form ValidatorMonolog Doctrine2 ORMTwigClassLoaderHttpKernel Doctrine2 ODM SwiftMailer Serializer Templating CSSSelectorConsole BrowserKit YamlProcessDomCrawler FinderThursday, May 12, 2011 6. A Bunch of Standalone LibsSymfony is a group of Routing HttpFoundation Doctrine2 DBAL Securitystandalone components andDependencyInjection EventDispatcher Assetic Translation other standalone PHP libraries Form ValidatorMonologDoctrine2 ORM Twig Decoupled building blocks forClassLoaderHttpKernel Doctrine2 ODM SwiftMailer Serializer any web application BrowserKit Templating CSSSelector Console YamlProcessDomCrawler FinderThursday, May 12, 2011 7. RoutingDependencyInjection HttpFoundation AsseticDoctrine2 DBALSecurity Form Validator HttpKernelEventDispatcher Doctrine2 ORMTwigTranslation ClassLoaderProcessTemplatingMonologCSSSelectorDoctrine2 ODM SwiftMailer SerializerYaml DomCrawler Console Finder BrowserKit What is the Symfony2 Framework? A set of bundles containing configurationand bridge classes These glue the components together, givingthe developer a consistent experienceThursday, May 12, 2011 8. RoutingDependencyInjection HttpFoundation AsseticDoctrine2 DBALSecurity Form Validator HttpKernelEventDispatcher Doctrine2 ORMTwigTranslation ClassLoaderProcessTemplatingMonologCSSSelectorDoctrine2 ODM SwiftMailer SerializerYaml DomCrawler Console Finder BrowserKit FrameworkBundleSecurityBundleDoctrineBundle TwigBundleMonologBundle SwiftmailerBundle WebProlerBundle AsseticBundle The Symfony2 FrameworkThursday, May 12, 2011 9. The Flexibility of Bundles A bundle is like a plugin, except that even thecore framework is implemented as bundles Your code is an equal citizen with the coreFrameworkBundleSecurityBundleAcmeBlogBundle AcmeTwigBundleTwigBundleMonologBundle AcmeAccountBundle WebProlerBundleThursday, May 12, 2011 10. Symfony2 is a set of standalone PHP componentlibraries, glued together by agroup of removable bundlesThursday, May 12, 2011 11. Act 2: Keep Things SimpleThursday, May 12, 2011 12. From space, the Web is stupid-simple the request /fooClientYour App(e.g. browser) FOO! the responseThursday, May 12, 2011 13. HTTP Request-Response Your job is always to generate and return a response Symfonys goal is to: take care of repetitive tasks (e.g. routing) allow your code to be organized offer optional tools for complex tasks (e.g. security, forms, etc) to stay the hell out of your way!Thursday, May 12, 2011 14. Keep it simple: write code that represents your business logic - dont bend to your frameworkThursday, May 12, 2011 15. Act 3: Symfony in ActionThursday, May 12, 2011 16. Symfony Distributions Symfony offers distributions (think Ubuntu) Download the Standard Distribution to instantly have a functional application Default Project Structure Common Sense default conguration Some demo pages to play with Start developing immediately!!!Thursday, May 12, 2011 17. Step 1: Get it! http://symfony.com/downloadThursday, May 12, 2011 18. Step 2: Unzip it!$ cd /path/to/webroot$ tar zxvf /path/to/Symfony_Standard_Vendors_2.0.0PR11.tgzThursday, May 12, 2011 19. Step 3: Run it!http://localhost/Symfony/web/cong.phpThursday, May 12, 2011 20. Step 3: Run it! This page identies any problems with your setup Fix them, then click Congure your Symfony Application online to continueThursday, May 12, 2011 21. Step 3: Congure it! If youre intoGUIs, Symfony offers one forsetting up yourbasic congurationThursday, May 12, 2011 22. Finished! This *is* your rst Symfony2pageThursday, May 12, 2011 23. Act 4: Lets create some pagesThursday, May 12, 2011 24. The 3 Steps to a Pagethe request! /hello/ryan Step1: Symfony matches the URL to a routeStep2: Symfony executes the controller (a the edge of aPHP function) of the routegiant ower! Step3: The controller (your code) returns aSymfony Response object the response! Hello ryan!Thursday, May 12, 2011 25. Hello {insert-name}! Our goal: to create a hello world-like app in two small steps...Thursday, May 12, 2011 26. Step1: Dene a route You dene the routes (URLs) of your app _welcome: / pattern: / defaults: { _controller: AcmeDemoBundle:Welcome:index } hello_demo:/hello/ryanpattern: /hello/{name} defaults: { _controller: AcmeDemoBundle:Meetup:hello }Thursday, May 12, 2011 27. Step1: Dene a routeAdd the following route to app/cong/routing.ymlhello_demo:pattern: /hello/{name}defaults: { _controller: AcmeDemoBundle:Meetup:hello } ** Routes can also be dened in XML, PHP and as annotationsThursday, May 12, 2011 28. Step 2: Symfony executes the controller of the routehello_demo:pattern: /hello/{name}defaults: { _controller: AcmeDemoBundle:Meetup:hello }AcmeDemoBundle:Meetup:hellois a shortcut forAcmeDemoBundleControllerMeetupController::helloAction()Symfony executes this PHP methodThursday, May 12, 2011 29. Step2: Create the controller