Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Podlaczenie Doctrine
Forum PHP.pl > Forum > PHP > Object-oriented programming
rad11
Probuje polaczyc doctrine do zwyklego projektu
http://doctrine-orm.readthedocs.org/en/lat...figuration.html

zastanawia mnie do czego ma prowadzic ta sciezka:

  1. /path/to/entity-files
Pyton_000
Ścieżka w której będą przechowywane Encje (klasy opisujące tabelę)
rad11
Nie wiem co robie zle

http://stackoverflow.com/questions/1116830...octrine-2-2-orm

korzystajac z tego posta robie tak jak jest opisane ale otrzymuje komunikat


  1. Warning: require(/\Doctrine\ORM\Configuration.php): failed to open stream: No such file or directory in C:\xampp\htdocs\doctrine\Doctrine\Common\ClassLoader.php on line 182
  2.  
  3. Fatal error: require(): Failed opening required '/\Doctrine\ORM\Configuration.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\doctrine\Doctrine\Common\ClassLoader.php on line 182


plik doctrine.php

  1. <?php
  2. use Doctrine\Common\ClassLoader,
  3. Doctrine\ORM\Configuration,
  4. Doctrine\ORM\EntityManager,
  5. Doctrine\Common\Cache\ArrayCache,
  6. Doctrine\DBAL\Logging\EchoSQLLogger;
  7.  
  8. class Doctrine{
  9.  
  10. public $em = null;
  11.  
  12. public function __construct()
  13. {
  14.  
  15. require_once 'Doctrine/Common/ClassLoader.php';
  16.  
  17. $doctrineClassLoader = new ClassLoader('Doctrine', '/');
  18. $doctrineClassLoader->register();
  19. $entitiesClassLoader = new ClassLoader('models', '/models/');
  20. $entitiesClassLoader->register();
  21. $proxiesClassLoader = new ClassLoader('Proxies', '/proxies/');
  22. $proxiesClassLoader->register();
  23.  
  24. // Set up caches
  25. $config = new Configuration;
  26. $cache = new ArrayCache;
  27. $config->setMetadataCacheImpl($cache);
  28. $driverImpl = $config->newDefaultAnnotationDriver(array('/models/Entities'));
  29. $config->setMetadataDriverImpl($driverImpl);
  30. $config->setQueryCacheImpl($cache);
  31.  
  32. $config->setQueryCacheImpl($cache);
  33.  
  34. // Proxy configuration
  35. $config->setProxyDir('/proxies');
  36. $config->setProxyNamespace('Proxies');
  37.  
  38. // Set up logger
  39. $logger = new EchoSQLLogger;
  40. //$config->setSQLLogger($logger);
  41.  
  42. $config->setAutoGenerateProxyClasses( TRUE );
  43.  
  44. // Database connection information
  45. $connectionOptions = array(
  46. 'driver' => 'pdo_mysql',
  47. 'user' => 'root',
  48. 'password' => '',
  49. 'host' => 'localhost',
  50. 'dbname' => 'baza'
  51. );
  52.  
  53. // Create EntityManager
  54. $this->em = EntityManager::create($connectionOptions, $config);
  55. }
  56. }



index.php

  1. <?php
  2. require "doctrine.php";
  3.  
  4. $doctrine = new Doctrine();
  5. $user = new models\User;
  6. $doctrine->em->persist($user);
  7. $doctrine->em->flush();
  8. ?>


Pomoze ktos zainstalowac ta biblioteke?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2024 Invision Power Services, Inc.