php - Doctrine 2. Cannot redeclare class Setup -
php - Doctrine 2. Cannot redeclare class Setup -
sometimes see error occurs when page loads, points base of operations class initialize doctrine 2 setup.
the problem error occurs through time , quite often, grab cause-effect relationship extremely difficult. however, sure problem has met someone. , may able prompt response.
thanks in advance.
error string: fatal error: cannot redeclare class doctrine\orm\tools\setup in /....hidden path..../lib/doctrineorm/doctrine/orm/tools/setup.php on line 34
class="lang-php prettyprint-override"><?php namespace doctrine\orm\tools; utilize doctrine\common\classloader; utilize doctrine\common\cache\cache; utilize doctrine\common\cache\arraycache; utilize doctrine\orm\configuration; utilize doctrine\orm\mapping\driver\xmldriver; utilize doctrine\orm\mapping\driver\yamldriver; /** * convenience class setting doctrine different installations , configurations. * * @author benjamin eberlei <kontakt@beberlei.de> */ class setup { /** * utilize method register autoloaders setup doctrine checked out * github repository @ {@link http://github.com/doctrine/doctrine2} * * @param string $gitcheckoutrootpath * @return void */ static public function registerautoloadgit($gitcheckoutrootpath) { if (!class_exists('doctrine\common\classloader', false)) { require_once $gitcheckoutrootpath . "/lib/vendor/doctrine-common/lib/doctrine/common/classloader.php"; } $loader = new classloader('doctrine\common', $gitcheckoutrootpath . "/lib/vendor/doctrine-common/lib"); $loader->register(); $loader = new classloader('doctrine\dbal', $gitcheckoutrootpath . "/lib/vendor/doctrine-dbal/lib"); $loader->register(); $loader = new classloader('doctrine\orm', $gitcheckoutrootpath . "/lib"); $loader->register(); $loader = new classloader('symfony\component', $gitcheckoutrootpath . "/lib/vendor"); $loader->register(); } /** * utilize method register autoloaders setup doctrine installed * though {@link http://pear.doctrine-project.org}. * * method registers autoloaders both doctrine , symfony top * level namespaces. * * @return void */ static public function registerautoloadpear() { if (!class_exists('doctrine\common\classloader', false)) { require_once "doctrine/common/classloader.php"; } $loader = new classloader("doctrine"); $loader->register(); $loader = new classloader("symfony"); $loader->register(); $classloader = new classloader('doctrineextensions', $lib . 'doctrineextensions'); $classloader->register(); } /** * utilize method register autoloads downloaded doctrine library. * pick directory library uncompressed into. * * @param string $directory */ static public function registerautoloaddirectory($directory) { if (!class_exists('doctrine\common\classloader', false)) { require_once $directory . "/doctrine/common/classloader.php"; } $loader = new classloader("doctrine", $directory); $loader->register(); $loader = new classloader('symfony\component', $directory . "/doctrine"); $loader->register(); $classloader = new classloader('doctrineextensions', $directory); $classloader->register(); } /** * create configuration annotation metadata driver. * * @param array $paths * @param boolean $isdevmode * @param string $proxydir * @param cache $cache * @param bool $usesimpleannotationreader * @return configuration */ static public function createannotationmetadataconfiguration(array $paths, $isdevmode = false, $proxydir = null, cache $cache = null, $usesimpleannotationreader = true) { $config = self::createconfiguration($isdevmode, $proxydir, $cache); $config->setmetadatadriverimpl($config->newdefaultannotationdriver($paths, $usesimpleannotationreader)); homecoming $config; } /** * create configuration xml metadata driver. * * @param array $paths * @param boolean $isdevmode * @param string $proxydir * @param cache $cache * @return configuration */ static public function createxmlmetadataconfiguration(array $paths, $isdevmode = false, $proxydir = null, cache $cache = null) { $config = self::createconfiguration($isdevmode, $proxydir, $cache); $config->setmetadatadriverimpl(new xmldriver($paths)); homecoming $config; } /** * create configuration yaml metadata driver. * * @param array $paths * @param boolean $isdevmode * @param string $proxydir * @param cache $cache * @return configuration */ static public function createyamlmetadataconfiguration(array $paths, $isdevmode = false, $proxydir = null, cache $cache = null) { $config = self::createconfiguration($isdevmode, $proxydir, $cache); $config->setmetadatadriverimpl(new yamldriver($paths)); homecoming $config; } /** * create configuration without metadata driver. * * @param bool $isdevmode * @param string $proxydir * @param cache $cache * @return configuration */ static public function createconfiguration($isdevmode = false, $proxydir = null, cache $cache = null) { $proxydir = $proxydir ?: sys_get_temp_dir(); if ($isdevmode === false && $cache === null) { if (extension_loaded('apc')) { $cache = new \doctrine\common\cache\apccache(); } else if (extension_loaded('xcache')) { $cache = new \doctrine\common\cache\xcachecache(); } else if (extension_loaded('memcache')) { $memcache = new \memcache(); $memcache->connect('127.0.0.1'); $cache = new \doctrine\common\cache\memcachecache(); $cache->setmemcache($memcache); } else if (extension_loaded('redis')) { $redis = new \redis(); $redis->connect('127.0.0.1'); $cache = new \doctrine\common\cache\rediscache(); $cache->setredis($redis); } else { $cache = new arraycache(); } } else if ($cache === null) { $cache = new arraycache(); } $cache->setnamespace("dc2_" . md5($proxydir) . "_"); // avoid collisions $config = new configuration(); $config->setmetadatacacheimpl($cache); $config->setquerycacheimpl($cache); $config->setresultcacheimpl($cache); $config->setproxydir($proxydir); $config->setproxynamespace('doctrineproxies'); $config->setautogenerateproxyclasses($isdevmode); homecoming $config; } }
the problem duplicated load entities.
php orm doctrine2
Comments
Post a Comment