我试图配置https://github.com/Atlantic18/DoctrineExtensions 使用https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/annotations.md#em-setup
指令但是我收到了一个错误:
The annotation "@Doctrine\ORM\Mapping\MappedSuperclass" in class Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation does not exist, or could not be auto-loaded\MappedSuperclass" in class Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation does not exist, or could not be auto-loaded.
我的配置
define('DB_CONNECTION', "host= ....");
$file_text_lib = __DIR__ . "/../../vendor/autoload.php";
require_once($file_text_lib);
// bootstrap.php
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Application;
use Doctrine\ORM\Version;
//use Doctrine\ORM\EntityManagerInterface;
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
define(
"PARSE_CONNECTION_STRING_REGEXP",
"/(\s*host\s*=\s*(?P<host>[^\s]+)|\s*port\s*=\s*(?P<port>[\d]+)|\s*dbname\s*=\s*(?P<dbname>[^\s]+)|\s*user\s*=\s*(?P<user>[^\s]+)|\s*password\s*=\s*(?P<password>[^\s]+)\s*)*/"
);
$isDevMode = true;
// globally used cache driver, in production use APC or memcached
$cache = new Doctrine\Common\Cache\ArrayCache;
// standard annotation reader
$annotationReader = new Doctrine\Common\Annotations\AnnotationReader;
$cachedAnnotationReader = new Doctrine\Common\Annotations\CachedReader(
$annotationReader, // use reader
$cache // and a cache driver
);
// create a driver chain for metadata reading
$driverChain = new Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain();
// load superclass metadata mapping only, into driver chain
// also registers Gedmo annotations.NOTE: you can personalize it
Gedmo\DoctrineExtensions::registerAbstractMappingIntoDriverChainORM(
$driverChain, // our metadata driver chain, to hook into
$cachedAnnotationReader // our cached annotation reader
);
// now we want to register our application entities,
// for that we need another metadata driver used for Entity namespace
$ymlDriver = new Doctrine\ORM\Mapping\Driver\YamlDriver(array(__DIR__."/YAMLMetaConfiguration"));
$driverChain->addDriver($ymlDriver, 'SemanticPersistence\\Entities');
// general ORM configuration
$config = new Doctrine\ORM\Configuration;
$config->setProxyDir(__DIR__ . "/../Proxies");
$config->setProxyNamespace('SemanticPersistence\\Proxies');
$config->setAutoGenerateProxyClasses($isDevMode); // this can be based on production config.
// register metadata driver
$config->setMetadataDriverImpl($driverChain);
// use our already initialized cache driver
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
$evm = new Doctrine\Common\EventManager();
// timestampable
$timestampableListener = new Gedmo\Timestampable\TimestampableListener;
$timestampableListener->setAnnotationReader($cachedAnnotationReader);
$evm->addEventSubscriber($timestampableListener);
//$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/Entities"), $isDevMode, null, null, false);
// or if you prefer yaml or XML
//$config = Setup::createXMLMetadataConfiguration(array(__DIR__."/config/xml"), $isDevMode);
/*
$config = Setup::createYAMLMetadataConfiguration(array(__DIR__."/YAMLMetaConfiguration"), $isDevMode);
$config->setAutoGenerateProxyClasses(true);
$config->setProxyDir(__DIR__ . "/../Proxies");
$config->setProxyNamespace('SemanticPersistence\\Proxies');
*/
preg_match(
PARSE_CONNECTION_STRING_REGEXP,
DB_CONNECTION,
$matches
);
$dbParams = array(
'driver' => 'pdo_pgsql',
'user' => $matches['user'],
'password' => $matches['password'],
'host' => $matches['host'],
'dbname' => $matches['dbname'],
'charset' => 'UTF-8'
);
if (!empty($matches['port'])) {
$dbParams['port'] = $matches['port'];
}
$entityManager = Doctrine\ORM\EntityManager::create($dbParams, $config, $evm);
$helperSet = new HelperSet(array(
'db' => new ConnectionHelper($entityManager->getConnection()),
'em' => new EntityManagerHelper($entityManager),
'dialog' => new QuestionHelper(),
));
$commands = array(
// DBAL Commands
new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
// ORM Commands
new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(),
new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(),
new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(),
new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(),
new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(),
new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(),
new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(),
new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(),
new \Doctrine\ORM\Tools\Console\Command\InfoCommand(),
//new \Doctrine\ORM\Tools\Console\Command\MappingDescribeCommand(),
);
$cli = new Application('Doctrine Command Line Interface', Version::VERSION);
$cli->setCatchExceptions(true);
$cli->setHelperSet($helperSet);
$cli->addCommands($commands);
$cli->run();
我做错了什么?
答案 0 :(得分:0)
忘记确保注册标准学说注释
Doctrine\Common\Annotations\AnnotationRegistry::registerFile(
__DIR__.'/../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'
);