OK. I give you all details with I have understand about the online
documentation.

1) Create the bundle:
php app/console init:bundle "Acme\MyBundle" src
> - The bundle "AcmeMyBundle" was created at "src/Acme/MyBundle" and is
> using the namespace "Acme\MyBundle".
> - The bundle contains a sample controller, a sample template and a sample > 
> routing file.

2) I add the following line to /app/AppKernel.php:
            new Acme\MyBundle\AcmeMyBundle(),

3) In app/config/config.yml:
doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                driver:   %database_driver%
                host:     %database_host%
                dbname:   %database_name%
                user:     %database_user%
                password: %database_password%
    orm:
        auto_generate_proxy_classes: %kernel.debug%
        default_entity_manager: default
        entity_managers:
            default:
                mappings:
                    AcmeMyBundle: ~

4) I create Entity directory in src/Acme/MyBundle
I create the class Acme.MyBundle.Entity.User.php in this directory
witch contains:

<?php
namespace Acme\MyBundle\Entity;

/**
 * Acme\MyBundle\Entity\User
 */
class User
{
    /**
     * @var integer $id
     */
    private $id;

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


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

    /**
     * Set pseudo
     *
     * @param string $pseudo
     */
    public function setPseudo($pseudo)
    {
        $this->pseudo = $pseudo;
    }

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

?>

5) DataBase creation:
php app/console doctrine:schema:create
> Creating database schema...
> Database schema created successfully!

6) Generation:
php app/console doctrine:generate:entities AcmeMyBundle
> Generating entities for "AcmeMyBundle"
>   generating Acme\MyBundle\Entity\User

==> Content of the User.php file generated automatically <==
<?php

namespace Acme\MyBundle\Entity;

/**
 * Acme\MyBundle\Entity\User
 */
class User
{
    /**
     * @var integer $id
     */
    private $id;

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


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

    /**
     * Set pseudo
     *
     * @param string $pseudo
     */
    public function setPseudo($pseudo)
    {
        $this->pseudo = $pseudo;
    }

    /**
     * Get pseudo
     *
     * @return string $pseudo
     */
    public function getPseudo()
    {
        return $this->pseudo;
    }
}
?>

7) Define an example in My Default Controller:

DefaultController:
namespace Acme\MyBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Acme\MyBundle\Entity\User;

class DefaultController extends Controller
{
    public function indexAction()
    {
        $user = new User();
        $user->setPseudo("JeanChristophe");
        $em = $this->get('doctrine.orm.entity_manager');
        $em->persist($user);
        $em->flush();
        return $this->render('AcmeMyBundle:Default:index.html.twig');
    }
}

7) I edit the route in app/config/route.yml by adding: (no external
routing because it is only for test)
my:
   pattern:  /mytest
   defaults: { _controller: AcmeMyBundle:Default:index }

8) And the error .... !!

GET /mytest HTTP/1.1:
> Class Acme\MyBundle\Entity\User is not a valid entity or mapped super class.
> 500 Internal Server Error - MappingException

Thanks in advance,
JeanChristophe.

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to