index.php 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Welcome to Doctrine 2.
  4. *
  5. * This is the index file of the sandbox. The first section of this file
  6. * demonstrates the bootstrapping and configuration procedure of Doctrine 2.
  7. * Below that section you can place your test code and experiment.
  8. */
  9. namespace Sandbox;
  10. use Doctrine\Common\ClassLoader,
  11. Doctrine\ORM\Configuration,
  12. Doctrine\ORM\EntityManager,
  13. Doctrine\Common\Cache\ApcCache,
  14. Entities\User, Entities\Address;
  15. require_once '../../lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';
  16. // Set up class loading. You could use different autoloaders, provided by your favorite framework,
  17. // if you want to.
  18. $classLoader = new ClassLoader('Doctrine\ORM', realpath(__DIR__ . '/../../lib'));
  19. $classLoader->register();
  20. $classLoader = new ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/../../lib/vendor/doctrine-dbal/lib'));
  21. $classLoader->register();
  22. $classLoader = new ClassLoader('Doctrine\Common', realpath(__DIR__ . '/../../lib/vendor/doctrine-common/lib'));
  23. $classLoader->register();
  24. $classLoader = new ClassLoader('Symfony', realpath(__DIR__ . '/../../lib/vendor'));
  25. $classLoader->register();
  26. $classLoader = new ClassLoader('Entities', __DIR__);
  27. $classLoader->register();
  28. $classLoader = new ClassLoader('Proxies', __DIR__);
  29. $classLoader->register();
  30. // Set up caches
  31. $config = new Configuration;
  32. $cache = new ApcCache;
  33. $config->setMetadataCacheImpl($cache);
  34. $driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities"));
  35. $config->setMetadataDriverImpl($driverImpl);
  36. $config->setQueryCacheImpl($cache);
  37. // Proxy configuration
  38. $config->setProxyDir(__DIR__ . '/Proxies');
  39. $config->setProxyNamespace('Proxies');
  40. $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
  41. // Database connection information
  42. $connectionOptions = array(
  43. 'driver' => 'pdo_sqlite',
  44. 'path' => 'database.sqlite'
  45. );
  46. // Create EntityManager
  47. $em = EntityManager::create($connectionOptions, $config);
  48. ## PUT YOUR TEST CODE BELOW
  49. $user = new User;
  50. $address = new Address;
  51. echo 'Hello World!' . PHP_EOL;