Hands-on with the Symfony2 Framework

download Hands-on with the Symfony2 Framework

of 73

  • date post

    06-May-2015
  • Category

    Technology

  • view

    18.642
  • download

    0

Embed Size (px)

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 of Hands-on with the Symfony2 Framework

  • 1.Hands on with Symfony2 Ryan Weaver @weaverryan

2. Who is this dude? Co-author of the Symfony2 Docs Core Symfony2 contributor Founder of KnpLabs US Geek, running, Nashvillehttp://www.twitter.com/weaverryanhttp://www.github.com/weaverryan 3. iostudio Advertising & Integrated Marketing Solutions A great, growing Nashville tech company Hiring good developers (of all backgrounds)to be part of a dynamic, fun teamhttp://iostudio.com/careers 4. KnpLabsQuality. Innovation. Excitement. Your symfony/Symfony2 development experts Consulting & application auditing Symfony2 Training Behind lots of open source initiatives 5. Symfony2 Training Right here in Nashville: May 19th & 20th real coding, real project Doctrine2, forms, security, caching, etc Cool libraries like Assetic, Imagine, Behat Lots more Or join us in New York City: June 6th & 7thhttp://bit.ly/symfony-training 6. Act 1:Meet Symfony 7. What is Symfony2?Symfony is a PHPFramework, a Philosophy, anda Community - all working together in harmony.symfony.com/what-is-symfony 8. Symfony2 A group of standalone PHP components Bundled into a full-service frameworkSolves your difcult, redundant problems... and then stays the hell out of the way 9. Problems Solved Data persistence Asset Management(via Doctrine) Routing Security File+Dir Traversing Forms Translation Validation Dependency Injection Templating Image Manipulation Autoloading Console Tasks Logging Caching 10. Act 2:Why Symfony2? 11. Symfony2 is fast By way of comparison, Symfony 2.0 is about 3 times faster than Version1.4 or than Zend Framework 1.10, while taking up 2 times less memory.http://symfony.com/six-good-technical-reasons 12. Symfony2 is full-featuredSymfony2 is an extremelyfull featured, modular, andcrazy fast framework.Steve FranciaVice President of Engineering at OpenSkyspf13.com/post/symfony2 13. Infinitely Flexible ArchitectureSymfony2 is probably one of themost exible PHP frameworks ever created. You can literally change everything.~ Blog.NewITFarmer.com http://bit.ly/symfony-new-it-farmer 14. A huge community of developers 167 core contributors 87 documentation contributors... and counting ... 15. A huge eco-system of open source libraries 223 open source Symfony2 bundles 74 open source Symfony2 projects ... and counting ... 16. Symfony2Bundles.org 223 open source bundles 74 open source projects http://symfony2bundles.org/ 17. Proven Reputation One of the most popular PHP frameworks inthe world First released in October 2005 Nearly 100 releases Powers a lot of big sitesnationalguard.com, dailymotion.com, exercise.com, shopopensky.com, etc 18. Act 3:Dive into Symfony 19. The Standard Distribution Symfony offers distributions (think Ubuntu) The Standard Distribution comes witheverything youll need + some bonuses Fully-functional application Intelligent default conguration Some demo pages we can play with 20. Step 1: Get it!symfony.com/download 21. Step 2: Unzip it!$ cd /path/to/webroot$ tar zxvf /path/to/Symfony_Standard_Vendors_2.0.0PR11.tgz 22. Step 3: Run it!http://localhost/Symfony/web/cong.php 23. Tend to your GardenFix any major problems (e.g. missing libraries, permissions issues) that Symfony reports Then click Congure your Symfony Application online 24. Step 3: Congure it! Optional: but anice interface toget you started quickly 25. Finished!This *is* yourrst Symfony2 page 26. Act 4:Lets create some pages 27. The 3 Steps to a Page/hello/ryanStep1: Symfony matches the URL to a routeStep2: Symfony executes the controller (aPHP function) of the routeStep3: The controller (your code) returns a Symfony Response objectHello ryan! 28. Hello {insert-name}! Our goal: to create a hello world-like app ... and then to make it do all sorts ofinteresting things ...remove half the code, JSON version, security,caching... 29. Step1: Symfony matches theURL to a routeYou dene the routes (URLs) of your app_welcome: /pattern: /defaults: { _controller: AcmeDemoBundle:Welcome:index }hello_demo:/hello/ryan pattern: /hello/{name}defaults: { _controller: AcmeDemoBundle:Meetup:hello } 30. Homework Add the following route toapp/cong/routing.yml hello_demo: pattern: /hello/{name} defaults: { _controller: AcmeDemoBundle:Meetup:hello }** Routes can also be dened in XML, PHP and as annotations 31. Step2: Symfony executes the controller of the routehello_demo:pattern: /hello/{name}defaults: { _controller: AcmeDemoBundle:Meetup:hello } Controller Class::method()AcmeDemoBundleControllerMeetupController::helloAction() Symfony will execute this PHP method 32. Homework Create the controller class: