I created YAML files to use with the command line tool to generate 
annotated entities. I'm then trying to using those in my web app. However, 
when I go to persist those entities it tells me "Class XXX is not a valid 
entity or mapped super class."

YAML definition:
Test\Entity\Thing:
  type: entity
  table: thing
  id:
    id:
      type: integer
      id: true
      generator:
        strategy: IDENTITY
  fields:
    name:
      type: string
      length: 100
      column: thing_name

I then use that to generate the entities with the following:
./doctrine orm:generate-entities --regenerate-entities=true --generate-
annotations=true ./app

Generated entity:
<?php

namespace Test\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Thing
 * 
 * @ORM\Table(name="thing")
 * @ORM\Entity
 */
class Thing
{
    /**
     * @var integer
     * 
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     * 
     * @ORM\Column(name="thing_name", type="string", length=100)
     */
    private $name;

    // generated getters/setters follow

Usage:
<?php
include 'vendor/autoload.php';
$config = Doctrine\ORM\Tools\Setup::createAnotationMetadataConfiguration(
array('app'));
$em = Doctrine\ORM\EntityManager::create($dbConfig, $config); // $dbConfig 
is an array of options passed to DBAL

$t = new Test\Entity\Thing();
$t->setName('Test Name');
$em->persist($t);
$em->flush();


-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to