Foros del Web » Programando para Internet » PHP » Symfony »

[SOLUCIONADO] [Desarrollo Web Agil Symfony2] Doctrine crea solo tabla Ciudad

Estas en el tema de [Desarrollo Web Agil Symfony2] Doctrine crea solo tabla Ciudad en el foro de Symfony en Foros del Web. Estimados, estoy leyendo Desarrollo Web Agil Symfony2 El libro recomendado por Symfony2 en ESP. Les comento, es este libro, me enseñan a crear Entidades (Entity) ...
  #1 (permalink)  
Antiguo 28/04/2013, 12:09
Avatar de SirDuque  
Fecha de Ingreso: febrero-2009
Ubicación: Paso del Rey, Buenos Aires, Argentina
Mensajes: 975
Antigüedad: 15 años, 2 meses
Puntos: 89
Sonrisa [Desarrollo Web Agil Symfony2] Doctrine crea solo tabla Ciudad

Estimados,
estoy leyendo Desarrollo Web Agil Symfony2 El libro recomendado por Symfony2 en ESP.

Les comento, es este libro, me enseñan a crear Entidades (Entity) por PHP, y luego con un simple:
doctrine:database:create
y
doctrine:schema:create

Se crea la DB y su esquema correspondiente a nuestro codigo.

Bueno, resulta que esto solo me crea una de seis tablas, coloco el comando doctrine:schema:create --dump-sql y el create que me muestra es solo el de la tabla ciudad.

Y no arroja ningún error.

Entiendo que me debe estar faltando alguna configuración, para que Doctrine lea los PHP con las entidades de las tablas faltantes.

Alguien me puede dar una mano con esto?
__________________
Mono programando!
twitter.com/eguimariano
  #2 (permalink)  
Antiguo 28/04/2013, 12:30
Avatar de masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: [Desarrollo Web Agil Symfony2] Doctrine crea solo tabla Ciudad

No esta detectando el mapeo de las entidades(asumiendo que este existe).

Saludos.
__________________
http://es.phptherightway.com/
thats us riders :)
  #3 (permalink)  
Antiguo 28/04/2013, 13:01
Avatar de SirDuque  
Fecha de Ingreso: febrero-2009
Ubicación: Paso del Rey, Buenos Aires, Argentina
Mensajes: 975
Antigüedad: 15 años, 2 meses
Puntos: 89
Respuesta: [Desarrollo Web Agil Symfony2] Doctrine crea solo tabla Ciudad

Cita:
Iniciado por masterpuppet Ver Mensaje
No esta detectando el mapeo de las entidades(asumiendo que este existe).

Saludos.
Si masterpuppet entiendo que ese es el problema.

Realice las siguientes pruebas:

Código:
$ php app/console doctrine:generate:entities VehiculoBundle
Y me arroja el siguiente error:

Código:
Generating entities for bundle "VehiculoBundle"


                                                                 
  [RuntimeException]                                             
  Bundle "VehiculoBundle" does not contain any mapped entities.  
                                                                 


doctrine:generate:entities [--path="..."] [--no-backup] name
Verifico que este bien las carpetas:

Código:
ll src/Sistema/VehiculoBundle/Entity
total 16
drwxr-sr-x 2 mge www-data 4096 abr 27 13:32 ./
drwxr-sr-x 7 mge www-data 4096 abr 27 13:32 ../
-rw-r--r-- 1 mge www-data 4772 abr 28 15:48 Vehiculo.php

$ ll src/Sistema/VehiculoBundle/Entity/Vehiculo.php
-rw-r--r-- 1 mge www-data 4772 abr 28 15:48 src/Sistema/VehiculoBundle/Entity/Vehiculo.php
Luego googleando el error me encuentro con esto:

http://forum.symfony-project.org/viewtopic

El cual indica que tenia un error de sintaxis en la definición de las rutas en el archivo.

Cito mi archivo:

Código PHP:
Ver original
  1. <?php
  2.  
  3. namespace Sistema\VehiculoBundle\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6.  
  7. /**
  8.  * @ORM\Entity
  9.  * @ORM\Table(name="ch_vehiculo")
  10.  */
  11. class Vehiculo
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\Column(type="integer")
  16.      * @ORM\GeneratedValue
  17.      */
  18.     protected $id;
  19.     /** @ORM\Column(type="string", length=50, unique=true)*/
  20.     protected $dominio;
  21.     /** @ORM\Column(type="string", length=50, unique=true)*/
  22.     protected $chasis;
  23.     /** @ORM\Column(type="string", length=50, unique=true)*/
  24.     protected $motor;
  25.     /** @ORM\Column(type="integer")*/
  26.     protected $seguro;
  27.     /** @ORM\Column(type="integer")*/
  28.     protected $kmAcumulado;
  29.     /** @ORM\Column(type="string")*/
  30.     protected $observacion;
  31.     /** @ORM\Column(type="datetime")*/
  32.     protected $alta;
  33.     /** @ORM\Column(type="datetime")*/
  34.     protected $baja;
  35.     /** @ORM\Column(type="integer")*/
  36.     protected $estado;
  37.     /** @ORM\Column(type="boolean")*/
  38.     protected $activo;
  39.  
  40.     /**
  41.      * Get id
  42.      *
  43.      * @return integer
  44.      */
  45.     public function getId()
  46.     {
  47.         return $this->id;
  48.     }
  49.  
  50.     /**
  51.      * Set dominio
  52.      *
  53.      * @param string $dominio
  54.      * @return Vehiculo
  55.      */
  56.     public function setDominio($dominio)
  57.     {
  58.         $this->dominio = $dominio;
  59.    
  60.         return $this;
  61.     }
  62.  
  63.     /**
  64.      * Get dominio
  65.      *
  66.      * @return string
  67.      */
  68.     public function getDominio()
  69.     {
  70.         return $this->dominio;
  71.     }
  72.  
  73.     /**
  74.      * Set chasis
  75.      *
  76.      * @param string $chasis
  77.      * @return Vehiculo
  78.      */
  79.     public function setChasis($chasis)
  80.     {
  81.         $this->chasis = $chasis;
  82.    
  83.         return $this;
  84.     }
  85.  
  86.     /**
  87.      * Get chasis
  88.      *
  89.      * @return string
  90.      */
  91.     public function getChasis()
  92.     {
  93.         return $this->chasis;
  94.     }
  95.  
  96.     /**
  97.      * Set motor
  98.      *
  99.      * @param string $motor
  100.      * @return Vehiculo
  101.      */
  102.     public function setMotor($motor)
  103.     {
  104.         $this->motor = $motor;
  105.    
  106.         return $this;
  107.     }
  108.  
  109.     /**
  110.      * Get motor
  111.      *
  112.      * @return string
  113.      */
  114.     public function getMotor()
  115.     {
  116.         return $this->motor;
  117.     }
  118.  
  119.     /**
  120.      * Set seguro
  121.      *
  122.      * @param string $seguro
  123.      * @return Vehiculo
  124.      */
  125.     public function setSeguro($seguro)
  126.     {
  127.         $this->seguro = $seguro;
  128.    
  129.         return $this;
  130.     }
  131.  
  132.     /**
  133.      * Get seguro
  134.      *
  135.      * @return string
  136.      */
  137.     public function getSeguro()
  138.     {
  139.         return $this->seguro;
  140.     }
  141.  
  142.     /**
  143.      * Set kmAcumulado
  144.      *
  145.      * @param string $kmAcumulado
  146.      * @return Vehiculo
  147.      */
  148.     public function setKmAcumulado($kmAcumulado)
  149.     {
  150.         $this->kmAcumulado = $kmAcumulado;
  151.    
  152.         return $this;
  153.     }
  154.  
  155.     /**
  156.      * Get kmAcumulado
  157.      *
  158.      * @return string
  159.      */
  160.     public function getKmAcumulado()
  161.     {
  162.         return $this->kmAcumulado;
  163.     }
  164.  
  165.     /**
  166.      * Set observacion
  167.      *
  168.      * @param string $observacion
  169.      * @return Vehiculo
  170.      */
  171.     public function setObservacion($observacion)
  172.     {
  173.         $this->Observacion = $observacion;
  174.    
  175.         return $this;
  176.     }
  177.  
  178.     /**
  179.      * Get observacion
  180.      *
  181.      * @return string
  182.      */
  183.     public function getObservacion()
  184.     {
  185.         return $this->observacion;
  186.     }
  187.  
  188.     /**
  189.      * Set alta
  190.      *
  191.      * @param datetime $alta
  192.      * @return Vehiculo
  193.      */
  194.     public function setAlta($alta)
  195.     {
  196.         $this->alta = $alta;
  197.    
  198.         return $this;
  199.     }
  200.  
  201.     /**
  202.      * Get alta
  203.      *
  204.      * @return datetime
  205.      */
  206.     public function getAlta()
  207.     {
  208.         return $this->alta;
  209.     }
  210.  
  211.     /**
  212.      * Set baja
  213.      *
  214.      * @param datetime $baja
  215.      * @return Vehiculo
  216.      */
  217.     public function setBaja($baja)
  218.     {
  219.         $this->baja = $baja;
  220.    
  221.         return $this;
  222.     }
  223.  
  224.     /**
  225.      * Get baja
  226.      *
  227.      * @return datetime
  228.      */
  229.     public function getBaja()
  230.     {
  231.         return $this->baja;
  232.     }
  233.     /**
  234.      * Set estado
  235.      *
  236.      * @param integer $estado
  237.      * @return Vehiculo
  238.      */
  239.     public function setEstado($estado)
  240.     {
  241.         $this->estado = $estado;
  242.    
  243.         return $this;
  244.     }
  245.  
  246.     /**
  247.      * Get estado
  248.      *
  249.      * @return integer
  250.      */
  251.     public function getEstado()
  252.     {
  253.         return $this->estado;
  254.     }
  255.  
  256.     /**
  257.      * Set activo
  258.      *
  259.      * @param boolean $activo
  260.      * @return Vehiculo
  261.      */
  262.     public function setActivo($activo)
  263.     {
  264.         $this->activo = $activo;
  265.    
  266.         return $this;
  267.     }
  268.  
  269.     /**
  270.      * Get activo
  271.      *
  272.      * @return boolean
  273.      */
  274.     public function getActivo()
  275.     {
  276.         return $this->activo;
  277.     }
  278.  
  279.     /**
  280.      * echo Class
  281.      * @return sting Id Dominio
  282.      */
  283.     public function __toString()
  284.     {
  285.         return "(".$this->getId().") ".$this->getDominio();
  286.     }
  287. }
__________________
Mono programando!
twitter.com/eguimariano
  #4 (permalink)  
Antiguo 28/04/2013, 13:02
Avatar de SirDuque  
Fecha de Ingreso: febrero-2009
Ubicación: Paso del Rey, Buenos Aires, Argentina
Mensajes: 975
Antigüedad: 15 años, 2 meses
Puntos: 89
Respuesta: [Desarrollo Web Agil Symfony2] Doctrine crea solo tabla Ciudad

En AppKernel.php esta:

Código PHP:
<?php

use SymfonyComponentHttpKernelKernel;
use 
SymfonyComponentConfigLoaderLoaderInterface;

class 
AppKernel extends Kernel
{
    public function 
registerBundles()
    {
        
$bundles = array(
            new 
SistemaCiudadBundleCiudadBundle(),
            new 
SistemaVehiculoBundleVehiculoBundle(),
Este es el codigo de Ciudad, el cual si funciona perfecto, con generate:entity y todo:
Código:
$ ll src/Sistema/CiudadBundle/Entity/Ciudad.php 
-rw-r--r-- 1 mge www-data 3438 abr 28 15:13 src/Sistema/CiudadBundle/Entity/Ciudad.php
Código PHP:
Ver original
  1. <?php
  2.  
  3. namespace Sistema\CiudadBundle\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6.  
  7. /**
  8.  * @ORM\Entity
  9.  * @ORM\Table(name="ch_ciudad")
  10.  */
  11. class Ciudad
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\Column(type="integer")
  16.      * @ORM\GeneratedValue
  17.      */
  18.     protected $id;
  19.     /** @ORM\Column(type="string", length=50, unique=true)*/
  20.     protected $nombre;
  21.     /** @ORM\Column(type="string", length=55, unique=true)*/
  22.     protected $slug;
  23.     /** @ORM\Column(type="string", length=12)*/
  24.     protected $codigoPostal;
  25.     /** @ORM\Column(type="integer")*/
  26.     protected $codigoArea;
  27.     /** @ORM\Column(type="datetime")*/
  28.     protected $alta;
  29.     /** @ORM\Column(type="datetime")*/
  30.     protected $baja;
  31.     /** @ORM\Column(type="boolean")*/
  32.     protected $activo;
  33.  
  34.     /**
  35.      * Get id
  36.      *
  37.      * @return integer
  38.      */
  39.     public function getId()
  40.     {
  41.         return $this->id;
  42.     }
  43.  
  44.     /**
  45.      * Set nombre
  46.      *
  47.      * @param string $nombre
  48.      * @return Ciudad
  49.      */
  50.     public function setNombre($nombre)
  51.     {
  52.         $this->nombre = $nombre;
  53.    
  54.         return $this;
  55.     }
  56.  
  57.     /**
  58.      * Get nombre
  59.      *
  60.      * @return string
  61.      */
  62.     public function getNombre()
  63.     {
  64.         return $this->nombre;
  65.     }
  66.  
  67.     /**
  68.      * Set slug
  69.      *
  70.      * @param string $slug
  71.      * @return Ciudad
  72.      */
  73.     public function setSlug($slug)
  74.     {
  75.         $this->slug = $slug;
  76.    
  77.         return $this;
  78.     }
  79.  
  80.     /**
  81.      * Get slug
  82.      *
  83.      * @return string
  84.      */
  85.     public function getSlug()
  86.     {
  87.         return $this->slug;
  88.     }
  89.  
  90.     /**
  91.      * Set codigoPostal
  92.      *
  93.      * @param string $codigoPostal
  94.      * @return Ciudad
  95.      */
  96.     public function setCodigoPostal($codigoPostal)
  97.     {
  98.         $this->codigoPostal = $codigoPostal;
  99.    
  100.         return $this;
  101.     }
  102.  
  103.     /**
  104.      * Get codigoPostal
  105.      *
  106.      * @return string
  107.      */
  108.     public function getCodigoPostal()
  109.     {
  110.         return $this->codigoPostal;
  111.     }
  112.  
  113.     /**
  114.      * Set codigoArea
  115.      *
  116.      * @param integer $codigoArea
  117.      * @return Ciudad
  118.      */
  119.     public function setCodigoArea($codigoArea)
  120.     {
  121.         $this->codigoArea = $codigoArea;
  122.    
  123.         return $this;
  124.     }
  125.  
  126.     /**
  127.      * Get codigoArea
  128.      *
  129.      * @return integer
  130.      */
  131.     public function getCodigoArea()
  132.     {
  133.         return $this->codigoArea;
  134.     }
  135.  
  136.     /**
  137.      * Set alta
  138.      *
  139.      * @param \datetime $alta
  140.      * @return Ciudad
  141.      */
  142.     public function setAlta($alta)
  143.     {
  144.         $this->alta = $alta;
  145.    
  146.         return $this;
  147.     }
  148.  
  149.     /**
  150.      * Get alta
  151.      *
  152.      * @return \datetime
  153.      */
  154.     public function getAlta()
  155.     {
  156.         return $this->alta;
  157.     }
  158.  
  159.     /**
  160.      * Set baja
  161.      *
  162.      * @param \datetime $baja
  163.      * @return Ciudad
  164.      */
  165.     public function setBaja($baja)
  166.     {
  167.         $this->baja = $baja;
  168.    
  169.         return $this;
  170.     }
  171.  
  172.     /**
  173.      * Get baja
  174.      *
  175.      * @return \datetime
  176.      */
  177.     public function getBaja()
  178.     {
  179.         return $this->baja;
  180.     }
  181.  
  182.     /**
  183.      * Set activo
  184.      *
  185.      * @param boolean $activo
  186.      * @return Ciudad
  187.      */
  188.     public function setActivo($activo)
  189.     {
  190.         $this->activo = $activo;
  191.    
  192.         return $this;
  193.     }
  194.  
  195.     /**
  196.      * Get activo
  197.      *
  198.      * @return boolean
  199.      */
  200.     public function getActivo()
  201.     {
  202.         return $this->activo;
  203.     }
  204.  
  205.     /**
  206.      * echo Class
  207.      * @return string Nombre
  208.      */
  209.     public function __toString()
  210.     {
  211.         return $this->getNombre();
  212.     }
  213. }
__________________
Mono programando!
twitter.com/eguimariano
  #5 (permalink)  
Antiguo 28/04/2013, 13:15
Avatar de masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: [Desarrollo Web Agil Symfony2] Doctrine crea solo tabla Ciudad

Postea la sección de doctrine del config.yml
__________________
http://es.phptherightway.com/
thats us riders :)
  #6 (permalink)  
Antiguo 28/04/2013, 13:23
Avatar de SirDuque  
Fecha de Ingreso: febrero-2009
Ubicación: Paso del Rey, Buenos Aires, Argentina
Mensajes: 975
Antigüedad: 15 años, 2 meses
Puntos: 89
Respuesta: [Desarrollo Web Agil Symfony2] Doctrine crea solo tabla Ciudad

// app/config/config.yml
Código YML:
Ver original
  1. # Doctrine Configuration
  2. doctrine:
  3.     dbal:
  4.         driver:   "%database_driver%"
  5.         host:     "%database_host%"
  6.         port:     "%database_port%"
  7.         dbname:   "%database_name%"
  8.         user:     "%database_user%"
  9.         password: "%database_password%"
  10.         charset:  UTF8
  11.  
  12.     orm:
  13.         auto_generate_proxy_classes: "%kernel.debug%"
  14.         auto_mapping: true

Dato: El archivo Ciudad.php de la ruta src/Sistema/CiudadBundle/Entity/Ciudad.php lo cree a mano, a Vehiculo.php lo cree con php app/console foctrine:generate:entity
__________________
Mono programando!
twitter.com/eguimariano
  #7 (permalink)  
Antiguo 28/04/2013, 13:45
Avatar de SirDuque  
Fecha de Ingreso: febrero-2009
Ubicación: Paso del Rey, Buenos Aires, Argentina
Mensajes: 975
Antigüedad: 15 años, 2 meses
Puntos: 89
Respuesta: [Desarrollo Web Agil Symfony2] Doctrine crea solo tabla Ciudad

Gracias masterpuppet,

Encontre el error: el problema fue mio al generar con php app/console doctrine:generate:entity en uno de los pasos me pregunta configuración del formato:
Código:
Determine the format to use for the mapping information.

Configuration format (yml, xml, php, or annotation) [annotation]: <Enter>
Yo estoy haciendo la configuracion por anotaciones, pero como las anotacione "comentarios" estan en PHP deduje que debia poner PHP en esa pregunta. ERROR era annotation.

Solucion:

Borrar la carpeta doctrine de: src/<proyecto>/<Bundle>/Resources/doctrine

Y listo, todo sale funcionando.

Saludos!!
__________________
Mono programando!
twitter.com/eguimariano

Etiquetas: ciudad, crea, doctrine, symfony2, tabla
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:39.