Introduction to Symfony2 - NYPHP

1,332 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,332
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
33
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Introduction to Symfony2 - NYPHP

  1. 1. INTRODUCTION TOSYMFONY2Juozas Kaziukėnas // juokaz.com // @juokaz
  2. 2. Juozas Kaziukėnas, LithuanianYou can call me JoeMore info http://juokaz.com
  3. 3. WHAT A FRAMEWORK SHOULD DO?
  4. 4. WHAT A FRAMEWORK SHOULD DO?• Out of the box functionality• Routing• Security• Best practices• Standardization• Development speed• etc.
  5. 5. WHAT IS SYMFONY2?
  6. 6. WHAT IS SYMFONY2?•A successor of symfony 1.X• Rewritten from scratch• Turns requests to responses, that’s it• Heavily utilizes PHP 5.3+ features• Component oriented architecture• Supported by Sensio Labs agency, run by Fabien Potencier
  7. 7. COMPONENTS• Building blocks for the framework• Like: HTTP kernel, Form, Validation, Security, Event dispatcher, Config, Console, etc.• Independent self-contained components• Can be used without using Symfony2 as a web framework
  8. 8. WHAT SYMFONY2 DOES WELL?
  9. 9. WHAT SYMFONY2 DOES WELL?• Components• Inspired Composer to be created• Silex vs Symfony2 vs your own• Fully working standard distribution• Service container for dependencies
  10. 10. SILEX require_once __DIR__./../vendor/autoload.php;$app = new SilexApplication();$app->get(/hello/{name}, function($name) use($app) { return Hello .$app->escape($name);});$app->run();
  11. 11. COMPOSER• 3rd party dependency management• Makes life so much easier• Allows not to have 3rd party checked in into a master repo• Project-specific dependencies vs PEAR-like system-wide• One file composer.json to manage all expectations• Became a de facto standard in PHP projects
  12. 12. STARTING WITH SYMFONY2
  13. 13. STARTING WITH SYMFONY2composer.phar create-projectsymfony/framework-standard-editionpath/to/install 2.1.x-devphp ./app/console server:runBrowse http://localhost:8000/app_dev.php
  14. 14. BUNDLES• “Modules” to separate application code• Contains controllers, models, templates, etc.• Symfony framework itself is a bundle called FrameworkBundle• Repository of available bundles http://knpbundles.com/• Can be extended to customize
  15. 15. BUNDLES// src/Acme/DemoBundle/Controller/WelcomeController.phpnamespace AcmeDemoBundleController;use SymfonyBundleFrameworkBundleControllerController;class WelcomeController extends Controller{ public function indexAction() { return $this->render(AcmeDemoBundle:Welcome:index.html.twig); }}
  16. 16. SERVICE CONTAINER // app/config/config.ymlservices: my_mailer: class: AcmeHelloBundleMailer arguments: [sendmail]class WelcomeController extends Controller{ public function sendEmailAction() { $mailer = $this->get(my_mailer); $mailer->send(ryan@foobar.net, ...); }}
  17. 17. COMMUNITY
  18. 18. COMMUNITY• Symfony2 on Twitter• Conferences, user groups• All of this? • Good market to be a developer • Less bugs, active GitHub• Drupal
  19. 19. QUESTIONS?
  20. 20. THANKS!Juozas Kaziukėnas @juokaz

×