0
votes

I have problem with use Doctrine\ORM\Mapping as ORM; I create project in Symfony2 and create some table in mysql. Then i import ENtities with:

php app/console doctrine:mapping:import AcmeMainBundle annotation

next, i generate entities

php app/console doctrine:generate:entities AcmeMainBundle

all looking good:

<?php
namespace Acme\MainBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Article
 *
 * @ORM\Table(name="article")
 * @ORM\Entity
 */
class Article
{
/**
 * @var integer
 *
 * @ORM\Column(name="id", type="integer", nullable=false)
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="IDENTITY")
 */
private $id;
.....

But, this orm not working. When I try use Repository:

* @ORM\Entity(repositoryClass="Acme\MainBundle\Repository\ArticleRepository")

and in there create own select with QueryBuilder, i dont see this function. In Controller I try see methods with:

var_dump(get_class_methods($this->getDoctrine()->getManager()->getRepository('AcmeMainBundle:Article')));

but return of this is only:

array (size=12)
0 => string '__construct' (length=11)
1 => string 'createQueryBuilder' (length=18)
2 => string 'createNamedQuery' (length=16)
3 => string 'createNativeNamedQuery' (length=22)
4 => string 'clear' (length=5)
5 => string 'find' (length=4)
6 => string 'findAll' (length=7)
7 => string 'findBy' (length=6)
8 => string 'findOneBy' (length=9)
9 => string '__call' (length=6)
10 => string 'getClassName' (length=12)
11 => string 'matching' (length=8)

without my function, after I find then any ORM dont working, when I try doing error in annotation

/**
 * Article
 *
 * @ORM\XXXXXXXXXXXXXXXXXTable(name="article")
 * @ORM\Entity
 */

I dont back any error.

I install Symfony2 and doctrine on Windows8 with composer with latest composer.json, all instalation step doing correctly.

app/autoload.php is:

<?php

use Doctrine\Common\Annotations\AnnotationRegistry;
use Composer\Autoload\ClassLoader;

/**
 * @var ClassLoader $loader
 */
$loader = require __DIR__.'/../vendor/autoload.php';

AnnotationRegistry::registerLoader(array($loader, 'loadClass'));

return $loader;

I dont know when I find this error. Entity working, but ORM mapping dont. Pls show me com clue, when I may find.

Thanks Stoupa

1
What is your PHP version? Symfony2 requires 5.3.8+ for annotations to work :) You can run php app/check.php to check if your installation is good enough to run symfony2. - danio1024
** Mandatory requirements ** OK PHP version must be at least 5.3.3 (5.3.13 installed) All requiments are OK. - Stoupa101
@Stoupa101, I had this error months ago, at that moment there was a php extension named "eAccelerator" recently installed in my server. So, when I disabled it temporally the doctrine error disappeared! - manix

1 Answers

0
votes

PROBLEM SOLVED: when I import Entity, I forget doing first step:

doctrine:mapping:convert --force --from-database xml ./src/Acme/MainBundle/Resources/config/doctrine/metadata/orm

with the next step:

doctrine:mapping:import AcmeMainBundle annotation

I see annotation but don't work.