introduction to symfony2 - nyphp
DESCRIPTION
TRANSCRIPT
![Page 1: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/1.jpg)
INTRODUCTION TO
SYMFONY2Juozas Kaziukėnas // juokaz.com // @juokaz
![Page 2: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/2.jpg)
Juozas Kaziukėnas, Lithuanian
You can call me Joe
More info http://juokaz.com
![Page 3: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/3.jpg)
WHAT A FRAMEWORK SHOULD DO?
![Page 4: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/4.jpg)
WHAT A FRAMEWORK SHOULD DO?
•Out of the box functionality• Routing• Security• Best practices• Standardization•Development speed• etc.
![Page 5: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/5.jpg)
WHAT IS SYMFONY2?
![Page 6: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/6.jpg)
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
![Page 7: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/7.jpg)
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
![Page 8: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/8.jpg)
WHAT SYMFONY2 DOES WELL?
![Page 9: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/9.jpg)
WHAT SYMFONY2 DOES WELL?
• Components• Inspired Composer to be created• Silex vs Symfony2 vs your own• Fully working standard distribution• Service container for dependencies
![Page 10: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/10.jpg)
SILEX
require_once __DIR__.'/../vendor/autoload.php';
$app = new Silex\Application();
$app->get('/hello/{name}', function($name) use($app) { return 'Hello '.$app->escape($name); });
$app->run();
![Page 11: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/11.jpg)
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
![Page 12: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/12.jpg)
STARTING WITH SYMFONY2
![Page 13: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/13.jpg)
STARTING WITH SYMFONY2
composer.phar create-project symfony/framework-standard-edition path/to/install 2.1.x-dev
php ./app/console server:run
Browse http://localhost:8000/app_dev.php
![Page 14: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/14.jpg)
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
![Page 15: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/15.jpg)
BUNDLES
// src/Acme/DemoBundle/Controller/WelcomeController.php
namespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class WelcomeController extends Controller{ public function indexAction() { return $this->render('AcmeDemoBundle:Welcome:index.html.twig'); }}
![Page 16: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/16.jpg)
SERVICE CONTAINER
// app/config/config.ymlservices: my_mailer: class: Acme\HelloBundle\Mailer arguments: [sendmail]
class WelcomeController extends Controller{ public function sendEmailAction() { $mailer = $this->get('my_mailer'); $mailer->send('[email protected]', ...); }}
![Page 17: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/17.jpg)
COMMUNITY
![Page 18: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/18.jpg)
COMMUNITY
• Symfony2 on Twitter• Conferences, user groups• All of this?• Good market to be a developer• Less bugs, active GitHub•Drupal
![Page 19: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/19.jpg)
QUESTIONS?
![Page 20: Introduction to Symfony2 - NYPHP](https://reader033.vdocument.in/reader033/viewer/2022051110/54c69b0c4a79593b258b464c/html5/thumbnails/20.jpg)
THANKS!Juozas Kaziukėnas
@juokaz