Migrare da symfony 1 a Symfony2
Upcoming SlideShare
Loading in...5
×
 

Migrare da symfony 1 a Symfony2

on

  • 1,067 views

 

Statistics

Views

Total Views
1,067
Slideshare-icon Views on SlideShare
1,057
Embed Views
10

Actions

Likes
2
Downloads
5
Comments
1

4 Embeds 10

https://twitter.com 4
https://si0.twimg.com 3
http://www.linkedin.com 2
http://www.sfexception.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

     Migrare da symfony 1 a Symfony2 Migrare da symfony 1 a Symfony2 Presentation Transcript

    • Migrare da symfony 1a Symfony2Massimiliano Arione @garakkio Torino, 5 ottobre 2012
    • symfony 1 end of life: nov. 2012
    • cosa non è Symfony 2
    • cosa non è Symfony 2
    • cosa è Symfony2
    • Dependency Injection Container
    • come funziona il DIC<?php$mailer = $this->get(mailer);
    • come funziona il DIC<?php$mailer = $this->get(mailer); niente più sfContext!
    • come funziona il DIC<?php$mailer = $this->get(newsletter);<?phpnamespace AcmeMyBundle;class Newsletter{ protected $mailer; public function __construct(Swift_Mailer $mailer) { $this->mailer = $mailer; }}
    • come funziona il DIC<?phpnamespace AcmeMyBundle;use DoctrineORMEntityManager;class Newsletter{ protected $mailer, $em; public function __construct(Swift_Mailer $mailer, EntityManager $em) { $this->mailer = $mailer; $this->em = $em; }}
    • test
    • model
    • model$ app/console doctrine:mapping:import AcmeMyBundle annotation$ app/console doctrine:generate:entities AcmeMyBundle --no-backup
    • model<?phpnamespace AcmeMyBundleEntity;use DoctrineORMMapping as ORM;/** * @ORMTable(name="category") * @ORMEntity */class Category{ /** * @ORMColumn(name="id", type="integer") * @ORMId * @ORMGeneratedValue(strategy="AUTO") */ private $id; /** * @ORMColumn(name="name", type="string", length=255) */ private $name;}
    • alcuni bundle da aggiungerestof/doctrine-extensions-bundlefriendsofsymfony/user-bundlesonata-project/doctrine-orm-admin-bundle
    • alcuni bundle da aggiungerestof/doctrine-extensions-bundle (sf1: behaviours)friendsofsymfony/user-bundle (sf1: sfGuardPlugin)sonata-project/doctrine-orm-admin-bundle (sf1: admin generator)
    • controller<?php /** * Lists all Category entities. * * @Route("/", name="category") * @Template() */ public function indexAction() { $em = $this->getDoctrine()->getManager(); $entities = $em->getRepository(AcmeMyBundle:Category)->findAll(); return array( entities => $entities, ); }
    • controller/** * @Route("/{id}/show", name="category_show") * @Template() */public function showAction($id){ $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository(AcmeMyBundle:Category)->find($id); if (!$entity) { throw $this->createNotFoundException(Unable to find Category entity.); } $deleteForm = $this->createDeleteForm($id); return array( entity => $entity, delete_form => $deleteForm->createView(), );}
    • /** * @Route("/create", name="category_create") * @Method("POST") controller * @Template("AcmeMyBundle:Category:new.html.twig") */ public function createAction(Request $request) { $entity = new Category(); $form = $this->createForm(new CategoryType(), $entity); $form->bind($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($entity); $em->flush(); return $this->redirect($this->generateUrl(category_show, array(id =>$entity->getId()))); } return array( entity => $entity, form => $form->createView(), ); }
    • view{% extends AcmeMyBundle::layout.html.twig %}{% block content %} <h1>Category list</h1> <table class="table table-striped table-hover table-bordered records_list"> <tbody> {% for entity in paginator %} <tr> <td><a href="{{ path(category_show, { id: entity.id }) }}">{{ entity.id}}</a></td> <td>{{ entity.name }}</td> <td class="btn-group"> {# ... #} </td> </tr> {% endfor %} </tbody> </table>{% endblock %}
    • cachehttp
    • domande?
    • grazie!linkshttp://twitter.com/garakkiohttp://www.slideshare.net/garakcreditshttp://text2pic.com/http://symfony.com/trademarkhttp://php.net/download-logos.phphttp://doophp.com/temp/guide/mvcabout.pnghttp://grigio.org/html5-linux-day/stuff/client-server.pnghttps://elearning.industriallogic.com/gh/albums/wrappersAndWalkers/injector/images/big-tomatoes.gifhttp://openclipart.org/image/800px/svg_to_png/94723/db.pnghttp://clivemind.com/wp-content/uploads/2012/07/logo.pnghttp://www.kidsvoting.dreamhosters.com/uploads/images/vote_1.jpghttp://markup.su/highlighter/