2017-07-27 4 views
-1

Ich versuche, die Entity Philip innerhalb eines Symfony-ControllerSymfony 2 Es wurde versucht, die Klasse "" aus dem Namespace zu laden "" Haben Sie eine Anweisung "use" für einen anderen Namespace vergessen? Zeige

Aber dieser Fehler zu verwenden, wenn ich will, um die Strecke laden:

Error Screenshot

Versuchte Klasse „PhilipRepositroy“ von Namensraum zu laden "AppBundle \ Repository" Haben Sie eine Anweisung "use" für einen anderen Namespace vergessen?

mein Controller

/** 
* @Route("/see", name="see") 
*/ 
public function SeeAction() 
{ 
    $Philip = $this->getDoctrine() 
     ->getRepository('AppBundle:Philip') 
     ->findAll(); 

    return $this->render('business/see.html.twig', array(
     'Philip' => $Philip 
    )); 
} 

Mein Philip Entity

<?php 

namespace AppBundle\Entity; 

use Doctrine\ORM\Mapping as ORM; 

/** 
* Philip 
*/ 
class Philip 
{ 
    /** 
    * @var int 
    */ 
    private $id; 

    /** 
    * @var string 
    */ 
    private $philipname; 

    /** 
    * @var string 
    */ 
    private $philipemail; 

    /** 
    * @var string 
    */ 
    private $philipphone; 

    /** 
    * @var string 
    */ 
    private $philipregion; 

    /** 
    * @var string 
    */ 
    private $philipville; 

    /** 
    * @var string 
    */ 
    private $philipcin; 

    /** 
    * @var string 
    */ 
    private $philipcv; 

    /** 
    * @var string 
    */ 
    private $philipgender; 


    /** 
    * Get id 
    * 
    * @return integer 
    */ 
    public function getId() 
    { 
     return $this->id; 
    } 

    /** 
    * Set philipname 
    * 
    * @param string $philipname 
    * @return Philip 
    */ 
    public function setPhilipname($philipname) 
    { 
     $this->philipname = $philipname; 

     return $this; 
    } 

    /** 
    * Get philipname 
    * 
    * @return string 
    */ 
    public function getPhilipname() 
    { 
     return $this->philipname; 
    } 

    /** 
    * Set philipemail 
    * 
    * @param string $philipemail 
    * @return Philip 
    */ 
    public function setPhilipemail($philipemail) 
    { 
     $this->philipemail = $philipemail; 

     return $this; 
    } 

    /** 
    * Get philipemail 
    * 
    * @return string 
    */ 
    public function getPhilipemail() 
    { 
     return $this->philipemail; 
    } 

    /** 
    * Set philipphone 
    * 
    * @param string $philipphone 
    * @return Philip 
    */ 
    public function setPhilipphone($philipphone) 
    { 
     $this->philipphone = $philipphone; 

     return $this; 
    } 

    /** 
    * Get philipphone 
    * 
    * @return string 
    */ 
    public function getPhilipphone() 
    { 
     return $this->philipphone; 
    } 

    /** 
    * Set philipregion 
    * 
    * @param string $philipregion 
    * @return Philip 
    */ 
    public function setPhilipregion($philipregion) 
    { 
     $this->philipregion = $philipregion; 

     return $this; 
    } 

    /** 
    * Get philipregion 
    * 
    * @return string 
    */ 
    public function getPhilipregion() 
    { 
     return $this->philipregion; 
    } 

    /** 
    * Set philipville 
    * 
    * @param string $philipville 
    * @return Philip 
    */ 
    public function setPhilipville($philipville) 
    { 
     $this->philipville = $philipville; 

     return $this; 
    } 

    /** 
    * Get philipville 
    * 
    * @return string 
    */ 
    public function getPhilipville() 
    { 
     return $this->philipville; 
    } 

    /** 
    * Set philipcin 
    * 
    * @param string $philipcin 
    * @return Philip 
    */ 
    public function setPhilipcin($philipcin) 
    { 
     $this->philipcin = $philipcin; 

     return $this; 
    } 

    /** 
    * Get philipcin 
    * 
    * @return string 
    */ 
    public function getPhilipcin() 
    { 
     return $this->philipcin; 
    } 

    /** 
    * Set philipcv 
    * 
    * @param string $philipcv 
    * @return Philip 
    */ 
    public function setPhilipcv($philipcv) 
    { 
     $this->philipcv = $philipcv; 

     return $this; 
    } 

    /** 
    * Get philipcv 
    * 
    * @return string 
    */ 
    public function getPhilipcv() 
    { 
     return $this->philipcv; 
    } 

    /** 
    * Set philipgender 
    * 
    * @param string $philipgender 
    * @return Philip 
    */ 
    public function setPhilipgender($philipgender) 
    { 
     $this->philipgender = $philipgender; 

     return $this; 
    } 

    /** 
    * Get philipgender 
    * 
    * @return string 
    */ 
    public function getPhilipgender() 
    { 
     return $this->philipgender; 
    } 
} 

Mein PhilipRepository

<?php 

namespace AppBundle\Repository; 

use Doctrine\ORM\EntityRepository; 

/** 
* PhilipRepository 
* 
* This class was generated by the Doctrine ORM. Add your own custom 
* repository methods below. 
*/ 
class PhilipRepository extends EntityRepository 
{ 
} 

Was kann ich tun, um dieses Problem zu lösen? Ich bin neu in Symfony

+0

Was ist der Sinn eines benutzerdefinierten Repository, wenn es keine benutzerdefinierten Funktionen enthält? – localheinz

Antwort

1

Also ich denke, Sie haben Repository-Klasse nicht erhalten? Dann in Ihren Philip Entitätsklasse Mappings hinzufügen

use Doctrine\ORM\Mapping as ORM; 

    /** 
    * @ORM\Entity(repositoryClass="AppBundle\Repository\PhilipRepository") 
    */ 
    class Philip 
    { 
     ... 
    } 
+0

ich füge diese Zeile und nichts hinzu Geändert, das gleiche Problem erscheint, danke –

+1

hast du Cache gelöscht? 'php bin/console cache: clear' Symfony Befehl oder manuell aus' var/cache' Verzeichnis? – ArtOsi

+0

Das Problem gelöst Nur in PhilipReposity ändere ich diese Zeile: Klasse PhilipRepository erweitert EntityRepository durch diese Zeile: (Klasse PhiliRepository erweitert \ Doctrine \ ORM \ EntityRepository) –

Verwandte Themen