doujiao1948 2011-11-22 16:51
浏览 39

没有框架的Doctrine ORM 2.1的cli-config.php的正确配置

i have this configuration for cli-config.php Doctrine CLI 2.2.0-DEV

<?php
require_once '../lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\ORM', realpath(__DIR__ . '/../lib'));
$classLoader->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('MyProject', __DIR__ );
$classloader->register();

$config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
//$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/mapping"));
$driverImpl = new Doctrine\ORM\Mapping\Driver\YamlDriver(realpath(__DIR__.'/mapping/yml/'));
//$driverImpl = new Doctrine\ORM\Mapping\Driver\XmlDriver(realpath(__DIR__.'/mapping/xml/'));

$config->setMetadataDriverImpl($driverImpl);

$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Proxies');


$connectionOptions = array(
    'driver'   => 'pdo_mysql',
    'path'     => '192.168.10.210',
    'dbname'   => 'my_database_name',
    'user'     => 'root',
    'password' => 'my_password'
);

$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);

$helpers = array(
    'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
    'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
);

i can generate YML files, XML files and Annotation hten i can get the Entitites but i can get proxies.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
    • ¥15 onvif+openssl,vs2022编译openssl64
    • ¥15 iOS 自定义输入法-第三方输入法
    • ¥15 很想要一个很好的答案或提示
    • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
    • ¥15 怀疑手机被监控,请问怎么解决和防止
    • ¥15 Qt下使用tcp获取数据的详细操作
    • ¥15 idea右下角设置编码是灰色的
    • ¥15 全志H618ROM新增分区
    • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示