From 7430320bac802095b773ab596c7c4215fc81f4e0 Mon Sep 17 00:00:00 2001 From: Gusakov Nikita Date: Sat, 18 May 2013 01:40:05 +0400 Subject: [PATCH 1/4] ready --- tools/sandbox/bootstrap.php | 0 tools/sandbox/cli-config.php | 36 ------------------------------------ 2 files changed, 36 deletions(-) create mode 100644 tools/sandbox/bootstrap.php delete mode 100644 tools/sandbox/cli-config.php diff --git a/tools/sandbox/bootstrap.php b/tools/sandbox/bootstrap.php new file mode 100644 index 000000000..e69de29bb diff --git a/tools/sandbox/cli-config.php b/tools/sandbox/cli-config.php deleted file mode 100644 index 2a34fd89b..000000000 --- a/tools/sandbox/cli-config.php +++ /dev/null @@ -1,36 +0,0 @@ -register(); -$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/../../lib/vendor/doctrine-dbal/lib')); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Common', realpath(__DIR__ . '/../../lib/vendor/doctrine-common/lib')); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Symfony', realpath(__DIR__ . '/../../lib/vendor')); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__); -$classLoader->register(); - -$config = new \Doctrine\ORM\Configuration(); -$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache); -$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities")); -$config->setMetadataDriverImpl($driverImpl); - -$config->setProxyDir(__DIR__ . '/Proxies'); -$config->setProxyNamespace('Proxies'); - -$connectionOptions = array( - 'driver' => 'pdo_sqlite', - 'path' => 'database.sqlite' -); - -$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config); - -$helpers = new Symfony\Component\Console\Helper\HelperSet(array( - 'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), - 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em) -)); \ No newline at end of file From dca0881d943b22d0d42bed5cd451611e6e9a0343 Mon Sep 17 00:00:00 2001 From: Gusakov Nikita Date: Sat, 18 May 2013 01:42:55 +0400 Subject: [PATCH 2/4] forget add changes --- tools/sandbox/bootstrap.php | 35 +++++++++++++++++++++++++++ tools/sandbox/doctrine.php | 22 ++++------------- tools/sandbox/index.php | 48 ++++--------------------------------- 3 files changed, 44 insertions(+), 61 deletions(-) diff --git a/tools/sandbox/bootstrap.php b/tools/sandbox/bootstrap.php index e69de29bb..0e7120544 100644 --- a/tools/sandbox/bootstrap.php +++ b/tools/sandbox/bootstrap.php @@ -0,0 +1,35 @@ +add('Entities', __DIR__); +$loader->add('Proxies', __DIR__); + +$config = new \Doctrine\ORM\Configuration(); + +// Set up Metadata Drivers +$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__ . "/Entities")); +$config->setMetadataDriverImpl($driverImpl); + +// Set up caches +$cache = new ApcCache; +$config->setMetadataCacheImpl($cache); +$config->setQueryCacheImpl($cache); +$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache); + +// Proxy configuration +$config->setProxyDir(__DIR__ . '/Proxies'); +$config->setProxyNamespace('Proxies'); + +// Database connection information +$connectionOptions = array( + 'driver' => 'pdo_sqlite', + 'path' => 'database.sqlite' +); + +return EntityManager::create($connectionOptions, $config); \ No newline at end of file diff --git a/tools/sandbox/doctrine.php b/tools/sandbox/doctrine.php index 9060e6f7b..66ed4f3c1 100644 --- a/tools/sandbox/doctrine.php +++ b/tools/sandbox/doctrine.php @@ -1,27 +1,15 @@ register(); -$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/../../lib/vendor/doctrine-dbal/lib')); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Common', realpath(__DIR__ . '/../../lib/vendor/doctrine-common/lib')); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Symfony', realpath(__DIR__ . '/../../lib/vendor')); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__); -$classLoader->register(); - -require __DIR__ . '/cli-config.php'; +$em = require_once __DIR__.'/bootstrap.php'; $cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\Common\Version::VERSION); $cli->setCatchExceptions(true); // Variable $helpers is defined inside cli-config.php -$cli->setHelperSet($helpers); +$cli->setHelperSet(new Symfony\Component\Console\Helper\HelperSet(array( + 'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), + 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em) +))); $cli->addCommands(array( // DBAL Commands diff --git a/tools/sandbox/index.php b/tools/sandbox/index.php index ad1cb9d6b..f866aeada 100644 --- a/tools/sandbox/index.php +++ b/tools/sandbox/index.php @@ -1,7 +1,7 @@ register(); -$classLoader = new ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/../../lib/vendor/doctrine-dbal/lib')); -$classLoader->register(); -$classLoader = new ClassLoader('Doctrine\Common', realpath(__DIR__ . '/../../lib/vendor/doctrine-common/lib')); -$classLoader->register(); -$classLoader = new ClassLoader('Symfony', realpath(__DIR__ . '/../../lib/vendor')); -$classLoader->register(); -$classLoader = new ClassLoader('Entities', __DIR__); -$classLoader->register(); -$classLoader = new ClassLoader('Proxies', __DIR__); -$classLoader->register(); - -// Set up caches -$config = new Configuration; -$cache = new ApcCache; -$config->setMetadataCacheImpl($cache); -$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities")); -$config->setMetadataDriverImpl($driverImpl); -$config->setQueryCacheImpl($cache); - -// Proxy configuration -$config->setProxyDir(__DIR__ . '/Proxies'); -$config->setProxyNamespace('Proxies'); -$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache); - -// Database connection information -$connectionOptions = array( - 'driver' => 'pdo_sqlite', - 'path' => 'database.sqlite' -); - -// Create EntityManager -$em = EntityManager::create($connectionOptions, $config); +$em = require_once __DIR__ . '/bootstrap.php'; ## PUT YOUR TEST CODE BELOW From ec57306efe40770d8a77bb92117e21252fa401c7 Mon Sep 17 00:00:00 2001 From: Gusakov Nikita Date: Sat, 18 May 2013 01:44:47 +0400 Subject: [PATCH 3/4] remove comment about cli-config --- tools/sandbox/doctrine.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/sandbox/doctrine.php b/tools/sandbox/doctrine.php index 66ed4f3c1..6cadae0d4 100644 --- a/tools/sandbox/doctrine.php +++ b/tools/sandbox/doctrine.php @@ -5,7 +5,6 @@ $em = require_once __DIR__.'/bootstrap.php'; $cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\Common\Version::VERSION); $cli->setCatchExceptions(true); -// Variable $helpers is defined inside cli-config.php $cli->setHelperSet(new Symfony\Component\Console\Helper\HelperSet(array( 'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em) From 1f4a65f3e05689b8725851d8bb88a0fc7f77b150 Mon Sep 17 00:00:00 2001 From: Gusakov Nikita Date: Mon, 20 May 2013 17:08:20 +0400 Subject: [PATCH 4/4] add debug variable and check for loader --- tools/sandbox/bootstrap.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/sandbox/bootstrap.php b/tools/sandbox/bootstrap.php index 0e7120544..5b97b9412 100644 --- a/tools/sandbox/bootstrap.php +++ b/tools/sandbox/bootstrap.php @@ -1,26 +1,32 @@ add('Entities', __DIR__); $loader->add('Proxies', __DIR__); +$debug = true; $config = new \Doctrine\ORM\Configuration(); // Set up Metadata Drivers $driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__ . "/Entities")); $config->setMetadataDriverImpl($driverImpl); -// Set up caches -$cache = new ApcCache; +// Set up caches, depending on $debug variable. +// You can use another variable to define which one of the cache systems you gonna use. +$cache = $debug ? new Cache\ArrayCache : new Cache\ApcCache; $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); -$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache); // Proxy configuration $config->setProxyDir(__DIR__ . '/Proxies');