introduction to symfony2 - zendstatic.zend.com/topics/symfony2-20130912.pdf · symfony2 is a...
TRANSCRIPT
![Page 1: Introduction to Symfony2 - Zendstatic.zend.com/topics/Symfony2-20130912.pdf · Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components that solve common](https://reader033.vdocuments.mx/reader033/viewer/2022050903/5bc1fac309d3f2840b8dcf23/html5/thumbnails/1.jpg)
![Page 2: Introduction to Symfony2 - Zendstatic.zend.com/topics/Symfony2-20130912.pdf · Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components that solve common](https://reader033.vdocuments.mx/reader033/viewer/2022050903/5bc1fac309d3f2840b8dcf23/html5/thumbnails/2.jpg)
Introduction to Symfony2
Andreas Hucks, SensioLabs Deutschland @meandmymonkey
![Page 3: Introduction to Symfony2 - Zendstatic.zend.com/topics/Symfony2-20130912.pdf · Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components that solve common](https://reader033.vdocuments.mx/reader033/viewer/2022050903/5bc1fac309d3f2840b8dcf23/html5/thumbnails/3.jpg)
What is Symfony2?
![Page 4: Introduction to Symfony2 - Zendstatic.zend.com/topics/Symfony2-20130912.pdf · Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components that solve common](https://reader033.vdocuments.mx/reader033/viewer/2022050903/5bc1fac309d3f2840b8dcf23/html5/thumbnails/4.jpg)
Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components
that solve common web development problems.
![Page 5: Introduction to Symfony2 - Zendstatic.zend.com/topics/Symfony2-20130912.pdf · Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components that solve common](https://reader033.vdocuments.mx/reader033/viewer/2022050903/5bc1fac309d3f2840b8dcf23/html5/thumbnails/5.jpg)
Symfony2 is also a full-stack web framework.
![Page 6: Introduction to Symfony2 - Zendstatic.zend.com/topics/Symfony2-20130912.pdf · Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components that solve common](https://reader033.vdocuments.mx/reader033/viewer/2022050903/5bc1fac309d3f2840b8dcf23/html5/thumbnails/6.jpg)
![Page 7: Introduction to Symfony2 - Zendstatic.zend.com/topics/Symfony2-20130912.pdf · Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components that solve common](https://reader033.vdocuments.mx/reader033/viewer/2022050903/5bc1fac309d3f2840b8dcf23/html5/thumbnails/7.jpg)
http://localhost/.../web/app_dev.php/
Front Controller
Environment The "rst page
![Page 8: Introduction to Symfony2 - Zendstatic.zend.com/topics/Symfony2-20130912.pdf · Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components that solve common](https://reader033.vdocuments.mx/reader033/viewer/2022050903/5bc1fac309d3f2840b8dcf23/html5/thumbnails/8.jpg)
Separation of Concerns Implementation
Controller
View Model
/hello/fabien The Controller analyses the user request, calls the Model and passes data to the View.
The View layer formats data in a dedicated format (html, json…)
The Model stores the business logic and classes that manipulate data.
R
Router
Request
![Page 9: Introduction to Symfony2 - Zendstatic.zend.com/topics/Symfony2-20130912.pdf · Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components that solve common](https://reader033.vdocuments.mx/reader033/viewer/2022050903/5bc1fac309d3f2840b8dcf23/html5/thumbnails/9.jpg)
Glossary
An Application is a directory containing the con"guration for a given set of Bundles
A Bundle is a structured set of "les that implements a single feature and which can be easily shared with other developers.
![Page 10: Introduction to Symfony2 - Zendstatic.zend.com/topics/Symfony2-20130912.pdf · Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components that solve common](https://reader033.vdocuments.mx/reader033/viewer/2022050903/5bc1fac309d3f2840b8dcf23/html5/thumbnails/10.jpg)
Creating a new Bundle
![Page 11: Introduction to Symfony2 - Zendstatic.zend.com/topics/Symfony2-20130912.pdf · Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components that solve common](https://reader033.vdocuments.mx/reader033/viewer/2022050903/5bc1fac309d3f2840b8dcf23/html5/thumbnails/11.jpg)
Routing Con!guration
![Page 12: Introduction to Symfony2 - Zendstatic.zend.com/topics/Symfony2-20130912.pdf · Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components that solve common](https://reader033.vdocuments.mx/reader033/viewer/2022050903/5bc1fac309d3f2840b8dcf23/html5/thumbnails/12.jpg)
class HelloController { /** * @Route("/hello/{name}") */ public function helloAction($name) { // ... } }
Annotation Con"guration
![Page 13: Introduction to Symfony2 - Zendstatic.zend.com/topics/Symfony2-20130912.pdf · Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components that solve common](https://reader033.vdocuments.mx/reader033/viewer/2022050903/5bc1fac309d3f2840b8dcf23/html5/thumbnails/13.jpg)
The Controller Layer
![Page 14: Introduction to Symfony2 - Zendstatic.zend.com/topics/Symfony2-20130912.pdf · Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components that solve common](https://reader033.vdocuments.mx/reader033/viewer/2022050903/5bc1fac309d3f2840b8dcf23/html5/thumbnails/14.jpg)
Generating a response namespace Sensio\Bundle\TrainingBundle\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Component\HttpFoundation\Response; class DefaultController { /** * @Route("/hello/{name}") */ public function indexAction($name) { return new Response(sprintf('Hello %s!', $name)); } }
![Page 15: Introduction to Symfony2 - Zendstatic.zend.com/topics/Symfony2-20130912.pdf · Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components that solve common](https://reader033.vdocuments.mx/reader033/viewer/2022050903/5bc1fac309d3f2840b8dcf23/html5/thumbnails/15.jpg)
The View Layer
![Page 16: Introduction to Symfony2 - Zendstatic.zend.com/topics/Symfony2-20130912.pdf · Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components that solve common](https://reader033.vdocuments.mx/reader033/viewer/2022050903/5bc1fac309d3f2840b8dcf23/html5/thumbnails/16.jpg)
// ... class DefaultController extends Controller { /** * @Route("/hello/{name}") */ public function indexAction($name) { $view = 'SensioTrainingBundle:Default:index.html.twig'; return $this->render($view, array('name' => $name)); } }
Rendering a view
![Page 17: Introduction to Symfony2 - Zendstatic.zend.com/topics/Symfony2-20130912.pdf · Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP 5.3 components that solve common](https://reader033.vdocuments.mx/reader033/viewer/2022050903/5bc1fac309d3f2840b8dcf23/html5/thumbnails/17.jpg)
Introduction to forms
Form
Data Source
POPO
Reads the data source
Reads the object
Writes the object
Normalization
Mapping
Validation