2016-06-02 12 views
0

Hell Freunde. Ich arbeite an einem symfony 2-Projekt, wo ich eine Crud-Operation hinzufügen muss. Ordnerstruktur ist src-> M2Catalyst-> M2MatchCut und Utilities. Unter M2MatchCut Ordner habe ich ein StoreBundle. Wo ich versuche, eine neue crud zu erzeugen wie wie folgt:Keine Route gefunden in Symfony 2.2.1 nach Generierung von CRUD

php app/console generate:doctrine:crud 
M2CatalystM2MatchCutStoreBundle:Partner 
"write" actions [no]? y 
Configuration format (yml, xml, php, or annotation) [annotation]:annotation 
Routes prefix [/partner]:null 
Do you confirm generation [yes]?y 

Meine routing.yml wie folgt

m2_catalyst_m2_match_cut_dubit: 
    resource: "@M2CatalystM2MatchCutDubitBundle/Controller/" 
    prefix: /

m2_catalyst_m2_match_cut_store: 
    resource: "@M2CatalystM2MatchCutStoreBundle/Controller/" 
    type: annotation 
    prefix: /product 


m2_catalyst_m2_match_cut_match_cut: 
    resource: "@M2CatalystM2MatchCutMatchCutBundle/Controller" 
    prefix: /matchcut 
    type:  annotation 

m2_catalyst_m2_match_cut_api: 
    resource: "@M2CatalystM2MatchCutApiBundle/Controller" 
    prefix: /api 
    type:  annotation 

homepage: 
    pattern:/
    defaults: { _controller: FOSUserBundle:Security:login } 

m2_catalyst_m2_match_cut_youtube_api: 
    resource: "@M2CatalystM2MatchCutYoutubeApiBundle/Controller" 
    prefix: /youtube 
    type:  annotation 


fos_user_security: 
    resource: "@FOSUserBundle/Resources/config/routing/security.xml" 

# Only login and basic security at first 

fos_user_profile: 
    resource: "@FOSUserBundle/Resources/config/routing/profile.xml" 
    prefix: /profile 

fos_user_register: 
    resource: "@FOSUserBundle/Resources/config/routing/registration.xml" 
    prefix: /register 

fos_user_resetting: 
    resource: "@FOSUserBundle/Resources/config/routing/resetting.xml" 
    prefix: /resetting 

fos_user_change_password: 
    resource: "@FOSUserBundle/Resources/config/routing/change_password.xml" 
    prefix: /profile 

m2_catalyst_m2_match_cut_user: 
    resource: "@M2CatalystM2MatchCutUserBundle/Resources/config/routing.yml" 
    prefix: /

m2_catalyst_m2_match_cut_home: 
    resource: "@M2CatalystM2MatchCutHomeBundle/Resources/config/routing.yml" 
    prefix: /


sonata_page_cache: 
    resource: '@SonataCacheBundle/Resources/config/routing/cache.xml' 
    prefix:/

# app/config/routing.yml 
admin: 
    resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml' 
    prefix:/

_sonata_admin: 
    resource: . 
    type: sonata_admin 
    prefix:/

gallery: 
    resource: '@SonataMediaBundle/Resources/config/routing/gallery.xml' 
    prefix: /media/gallery 

media: 
    resource: '@SonataMediaBundle/Resources/config/routing/media.xml' 
    prefix: /media 

Aber wenn ich versuche, M2Catalyst/web/app_dev.php/m2matchcut/zugreifen store/movie es heißt Es wurde keine Route gefunden für "GET/m2matchcut/store/movie"

Was läuft falsch, kann jemand helfen?

Mein Controller-Klasse PartnerController wie folgt:

<?php 

namespace M2Catalyst\M2MatchCut\StoreBundle\Controller; 

use Symfony\Component\HttpFoundation\Request; 
use Symfony\Bundle\FrameworkBundle\Controller\Controller; 
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; 
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; 
use M2Catalyst\M2MatchCut\StoreBundle\Entity\Partner; 
use M2Catalyst\M2MatchCut\StoreBundle\Form\PartnerType; 

/** 
* Partner controller. 
* 
* @Route("/partner") 
*/ 
class PartnerController extends Controller 
{ 

    /** 
    * Lists all Partner entities. 
    * 
    * @Route("/", name="partner") 
    * @Method("GET") 
    * @Template() 
    */ 
    public function indexAction() 
    { 
     $em = $this->getDoctrine()->getManager(); 

     $entities = $em->getRepository('M2CatalystM2MatchCutStoreBundle:Partner')->findAll(); 

     return array(
      'entities' => $entities, 
     ); 
    } 
    /** 
    * Creates a new Partner entity. 
    * 
    * @Route("/", name="partner_create") 
    * @Method("POST") 
    * @Template("M2CatalystM2MatchCutStoreBundle:Partner:new.html.twig") 
    */ 
    public function createAction(Request $request) 
    { 
     $entity = new Partner(); 
     $form = $this->createForm(new PartnerType(), $entity); 
     $form->bind($request); 

     if ($form->isValid()) { 
      $em = $this->getDoctrine()->getManager(); 
      $em->persist($entity); 
      $em->flush(); 

      return $this->redirect($this->generateUrl('partner_show', array('id' => $entity->getId()))); 
     } 

     return array(
      'entity' => $entity, 
      'form' => $form->createView(), 
     ); 
    } 

    /** 
    * Displays a form to create a new Partner entity. 
    * 
    * @Route("/new", name="partner_new") 
    * @Method("GET") 
    * @Template() 
    */ 
    public function newAction() 
    { 
     $entity = new Partner(); 
     $form = $this->createForm(new PartnerType(), $entity); 

     return array(
      'entity' => $entity, 
      'form' => $form->createView(), 
     ); 
    } 

    /** 
    * Finds and displays a Partner entity. 
    * 
    * @Route("/{id}", name="partner_show") 
    * @Method("GET") 
    * @Template() 
    */ 
    public function showAction($id) 
    { 
     $em = $this->getDoctrine()->getManager(); 

     $entity = $em->getRepository('M2CatalystM2MatchCutStoreBundle:Partner')->find($id); 

     if (!$entity) { 
      throw $this->createNotFoundException('Unable to find Partner entity.'); 
     } 

     $deleteForm = $this->createDeleteForm($id); 

     return array(
      'entity'  => $entity, 
      'delete_form' => $deleteForm->createView(), 
     ); 
    } 

    /** 
    * Displays a form to edit an existing Partner entity. 
    * 
    * @Route("/{id}/edit", name="partner_edit") 
    * @Method("GET") 
    * @Template() 
    */ 
    public function editAction($id) 
    { 
     $em = $this->getDoctrine()->getManager(); 

     $entity = $em->getRepository('M2CatalystM2MatchCutStoreBundle:Partner')->find($id); 

     if (!$entity) { 
      throw $this->createNotFoundException('Unable to find Partner entity.'); 
     } 

     $editForm = $this->createForm(new PartnerType(), $entity); 
     $deleteForm = $this->createDeleteForm($id); 

     return array(
      'entity'  => $entity, 
      'edit_form' => $editForm->createView(), 
      'delete_form' => $deleteForm->createView(), 
     ); 
    } 

    /** 
    * Edits an existing Partner entity. 
    * 
    * @Route("/{id}", name="partner_update") 
    * @Method("PUT") 
    * @Template("M2CatalystM2MatchCutStoreBundle:Partner:edit.html.twig") 
    */ 
    public function updateAction(Request $request, $id) 
    { 
     $em = $this->getDoctrine()->getManager(); 

     $entity = $em->getRepository('M2CatalystM2MatchCutStoreBundle:Partner')->find($id); 

     if (!$entity) { 
      throw $this->createNotFoundException('Unable to find Partner entity.'); 
     } 

     $deleteForm = $this->createDeleteForm($id); 
     $editForm = $this->createForm(new PartnerType(), $entity); 
     $editForm->bind($request); 

     if ($editForm->isValid()) { 
      $em->persist($entity); 
      $em->flush(); 

      return $this->redirect($this->generateUrl('partner_edit', array('id' => $id))); 
     } 

     return array(
      'entity'  => $entity, 
      'edit_form' => $editForm->createView(), 
      'delete_form' => $deleteForm->createView(), 
     ); 
    } 
    /** 
    * Deletes a Partner entity. 
    * 
    * @Route("/{id}", name="partner_delete") 
    * @Method("DELETE") 
    */ 
    public function deleteAction(Request $request, $id) 
    { 
     $form = $this->createDeleteForm($id); 
     $form->bind($request); 

     if ($form->isValid()) { 
      $em = $this->getDoctrine()->getManager(); 
      $entity = $em->getRepository('M2CatalystM2MatchCutStoreBundle:Partner')->find($id); 

      if (!$entity) { 
       throw $this->createNotFoundException('Unable to find Partner entity.'); 
      } 

      $em->remove($entity); 
      $em->flush(); 
     } 

     return $this->redirect($this->generateUrl('partner')); 
    } 

    /** 
    * Creates a form to delete a Partner entity by id. 
    * 
    * @param mixed $id The entity id 
    * 
    * @return \Symfony\Component\Form\Form The form 
    */ 
    private function createDeleteForm($id) 
    { 
     return $this->createFormBuilder(array('id' => $id)) 
      ->add('id', 'hidden') 
      ->getForm() 
     ; 
    } 
} 
+0

zeigen Sie Ihre Controller-Klasse –

+0

aktualisiert, um die oben gestellte Frage @ Andrzej –

Antwort

0

Ihr Weg falsch ist.

Wenn Sie index von Ihrem Controller machen will, sollte dieser Weg für diese Route Konfiguration arbeiten:

.../app_dev.php/movie/partner 
+0

Eigentlich habe ich versucht, einen anderen crud namens Film zu machen. und habe versucht, das mit dem Präfix/im Routing zu definieren. Das wurde nach dem Film geändert. Ich lösche diesen Teil des Codes jetzt von routing.yml 'm2_catalyst_m2_match_cut_store_movie: Ressource:" @ M2CatalystM2MatchCutStoreBundle/Controller/" Typ: Annotation Präfix:/Film' –

Verwandte Themen