I want to visualize data from a database with Doctrine, but it doesn't seems to work...
Here's my class Organization
:
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**Class Organization
* @package AppBundle\Entity
*
* @ORM\Table(name="organization")
* @ORM\Entity(repositoryClass="AppBundle\Repository\
* OrganizationRepository")
*
*/
class Organization
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
* @ORM\Column(name="name", type="string", length=45)
*
*/
protected $name;
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
}
Here's the error:
Doctrine\ORM\Mapping\MappingException: Class "AppBundle\Entity\Organization" is not a valid entity or mapped super class.
at vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php:346 at Doctrine\ORM\Mapping\MappingException::classIsNotAValidEntityOrMappedSuperClass('AppBundle\Entity\Organization') (vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php:91) at Doctrine\ORM\Mapping\Driver\AnnotationDriver->loadMetadataForClass('AppBundle\Entity\Organization', object(ClassMetadata)) (vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php:102) at Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain->loadMetadataForClass('AppBundle\Entity\Organization', object(ClassMetadata)) (vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:151) at Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata(object(ClassMetadata), null, false, array()) (vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:332) at Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata('AppBundle\Entity\Organization') (vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:78) at Doctrine\ORM\Mapping\ClassMetadataFactory->loadMetadata('AppBundle\Entity\Organization') (vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:216) at Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor('AppBundle:Organization') (vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:281) at Doctrine\ORM\EntityManager->getClassMetadata('AppBundle:Organization') (vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php:44) at Doctrine\ORM\Repository\DefaultRepositoryFactory->getRepository(object(EntityManager), 'AppBundle:Organization') (vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:698) at Doctrine\ORM\EntityManager->getRepository('AppBundle:Organization') (src/AppBundle/Controller/OrganizationController.php:27) at AppBundle\Controller\OrganizationController->showInfoAction() at call_user_func_array(array(object(OrganizationController), 'showInfoAction'), array()) (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:153) at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1) (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68) at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true) (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:171) at Symfony\Component\HttpKernel\Kernel->handle(object(Request)) (web/app_dev.php:29)
I have the OrganizationController
and the OrganizationRepository
.
@ORM\Entity(repositoryClass
you have line break and that might be the reason. – Tomasz