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

[SOLUCIONADO] Doctrine 2.1.7 y zf 1.12

Estas en el tema de Doctrine 2.1.7 y zf 1.12 en el foro de Zend en Foros del Web. Hola: he instalado Doctrine en C:\xampp\htdocs\biblioteca\library: Cita: bin - cli-config.php - doctrine - doctrine.php - doctrine.bat Doctrine - Common - DBAL - ORM - Symfony ...
  #1 (permalink)  
Antiguo 05/03/2013, 14:52
 
Fecha de Ingreso: enero-2010
Mensajes: 491
Antigüedad: 14 años, 3 meses
Puntos: 12
Doctrine 2.1.7 y zf 1.12

Hola:

he instalado Doctrine en C:\xampp\htdocs\biblioteca\library:
Cita:
bin
- cli-config.php
- doctrine
- doctrine.php
- doctrine.bat
Doctrine
- Common
- DBAL
- ORM
- Symfony
el cli-config.php es:
Código PHP:
Ver original
  1. require_once '/../Doctrine/Common/ClassLoader.php';
  2.  
  3. $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\ORM', realpath(__DIR__));
  4. $classLoader->register();
  5. $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', realpath(__DIR__));
  6. $classLoader->register();
  7. $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Common', realpath(__DIR__));
  8. $classLoader->register();
  9. $classLoader = new \Doctrine\Common\ClassLoader('Symfony', realpath(__DIR__));
  10. $classLoader->register();
  11. $classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__);
  12. $classLoader->register();
  13. $classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__);
  14. $classLoader->register();
  15.  
  16. $config = new \Doctrine\ORM\Configuration();
  17. $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
  18. $driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities"));
  19. $config->setMetadataDriverImpl($driverImpl);
  20.  
  21. $config->setProxyDir(__DIR__ . '/Proxies');
  22. $config->setProxyNamespace('Proxies');
  23.  
  24. /*$connectionOptions = array(
  25.         'driver' => 'pdo_sqlite',
  26.         'path' => 'database.sqlite'
  27. );*/
  28. $dbParams = array(
  29.         'driver'   => 'pdo_mysql',
  30.         'user'     => 'root',
  31.         'password' => '',
  32.         'dbname'   => 'biblioteca',
  33. );
  34.  
  35. $em = \Doctrine\ORM\EntityManager::create($dbParams, $config);
  36.  
  37. $helpers = new Symfony\Component\Console\Helper\HelperSet(array(
  38.         'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
  39.         'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
  40. ));
la ejecución de 'php doctrine' no tiene ningun problema, pero cuando ejecuto: 'php doctrine orm:schema-tool:create' me lanza lo siguiente:
Cita:
[Doctrine\ORM\Mapping\MappingException]

File mapping drivers must have a valid directory path, however the given path
[C:\xampp\htdocs\biblioteca\library\bin/Entities] seems to be incorrect!
no se cuanto tenga que ver el siguiente comando 'php cli-config.php' me da esto:
Cita:
Warning: require(C:\xampp\htdocs\biblioteca\library\bin\Doc trine\ORM\Configuration.php): failed to open stream: No such file or directory in C:\xampp\htdocs\biblioteca\library\Doctrine\Common \ClassLoader.php on line 148

Fatal error: require(): Failed opening required 'C:\xampp\htdocs\biblioteca\library\bin\Doctrine\O RM\Configuration.php' (include_path='.;C:\xampp\php\library;C:\xampp\php \PEAR') in C:\xampp\htdocs\biblioteca\library\Doctrine\Common \ClassLoader.php on line 148
Quisiera aprender más sobre ORM, agradecería su ayuda.
  #2 (permalink)  
Antiguo 05/03/2013, 16:54
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: Doctrine 2.1.7 y zf 1.12

Te sugiero que utilices la integración "oficial" https://github.com/guilhermeblanco/z...ork1-doctrine2

Saludos.
__________________
http://es.phptherightway.com/
thats us riders :)
  #3 (permalink)  
Antiguo 06/03/2013, 07:24
 
Fecha de Ingreso: enero-2010
Mensajes: 491
Antigüedad: 14 años, 3 meses
Puntos: 12
Respuesta: Doctrine 2.1.7 y zf 1.12

Gracias masterpuppet, lo que hice fue crear una carpeta Entities al nivel de la carpeta Doctrine y bin, dentro de esta agregué User.php con el siguiente código:
Código PHP:
Ver original
  1. namespace Entities;
  2.  
  3. use Doctrine\ORM\Mapping as ORM;
  4.  
  5. /**
  6.  * Entities\User
  7.  *
  8.  * @Table(name="user")
  9.  * @Entity(repositoryClass="Repository\User")
  10.  */
  11. class User
  12. {
  13.     /**
  14.      * @var integer $id
  15.      *
  16.      * @Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
  17.      * @Id
  18.      * @GeneratedValue(strategy="IDENTITY")
  19.      */
  20.     private $id;
  21.  
  22.     /**
  23.      * @var string $userName
  24.      *
  25.      * @Column(name="userName", type="string", length=45, precision=0, scale=0, nullable=false, unique=false)
  26.      */
  27.     private $userName;
  28.  
  29.     /**
  30.      * @var string $email
  31.      *
  32.      * @Column(name="email", type="string", length=45, precision=0, scale=0, nullable=false, unique=false)
  33.      */
  34.     private $email;
  35.  
  36.     /**
  37.      * @var text $bio
  38.      *
  39.      * @Column(name="bio", type="text", precision=0, scale=0, nullable=true, unique=false)
  40.      */
  41.     private $bio;
  42.  
  43.  
  44.     /**
  45.      * Get id
  46.      *
  47.      * @return integer
  48.      */
  49.     public function getId()
  50.     {
  51.         return $this->id;
  52.     }
  53.  
  54.     /**
  55.      * Set userName
  56.      *
  57.      * @param string $userName
  58.      */
  59.     public function setUserName($userName)
  60.     {
  61.         $this->userName = $userName;
  62.     }
  63.  
  64.     /**
  65.      * Get userName
  66.      *
  67.      * @return string
  68.      */
  69.     public function getUserName()
  70.     {
  71.         return $this->userName;
  72.     }
  73.  
  74.     /**
  75.      * Set email
  76.      *
  77.      * @param string $email
  78.      */
  79.     public function setEmail($email)
  80.     {
  81.         $this->email = $email;
  82.     }
  83.  
  84.     /**
  85.      * Get email
  86.      *
  87.      * @return string
  88.      */
  89.     public function getEmail()
  90.     {
  91.         return $this->email;
  92.     }
  93.  
  94.     /**
  95.      * Set bio
  96.      *
  97.      * @param text $bio
  98.      */
  99.     public function setBio($bio)
  100.     {
  101.         $this->bio = $bio;
  102.     }
  103.  
  104.     /**
  105.      * Get bio
  106.      *
  107.      * @return text
  108.      */
  109.     public function getBio()
  110.     {
  111.         return $this->bio;
  112.     }
  113. }
antes tube que crear la base de datos biblioteca que indica en la linea 32 de cli-config.php
Ejecuté 'php doctrine orm:schema-tool:create' y generó la tabla user, que era lo que estaba buscando.

Etiquetas: doctrine
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 10:12.