doctrine/doctrine-oxm-bundle

此软件包已被废弃,不再维护。没有建议的替代软件包。

Symfony2 DoctrineOXMBundle

安装: 4

依赖者: 1

建议者: 0

安全: 0

星级: 12

关注者: 10

分支: 9

类型:symfony-bundle

dev-master 2012-01-04 03:45 UTC

This package is auto-updated.

Last update: 2022-02-01 12:20:01 UTC


README

Doctrine OXM 是一个 PHP 5.3 项目,用于 PHP 对象到 XML 映射,它提供了通过常见的 Doctrine 技术将 XML 持久化到文件系统的支持。

安装

要使用 OXM,你需要 Doctrine 提供的 OXM 库以及一个将这些库集成到 Symfony 中的软件包。如果你使用的是 Symfony 标准发行版,请将以下内容添加到项目根目录的 deps 文件中

[doctrine-oxm]
    git=http://github.com/doctrine/oxm.git
    target=/doctrine-oxm

[DoctrineOXMBundle]
    git=http://github.com/doctrine/DoctrineOXMBundle.git
    target=/bundles/Doctrine/Bundle/OXMBundle

现在,通过运行以下命令来更新供应商库

$ php bin/vendors install

接下来,将 Doctrine\OXM 和 Doctrine\Bundle\OXMBundle 命名空间添加到 app/autoload.php 文件中,以便这些库可以被自动加载。确保将它们添加到 Doctrine 命名空间(如上所示)的任何地方以上

// app/autoload.php
$loader->registerNamespaces(array(
    // ...
    'Doctrine\\OXM'             => __DIR__.'/../vendor/doctrine-oxm/lib',
    'Doctrine\\Bundle'          => __DIR__.'/../vendor/bundles',
    // ...
));

使用 OXM 注解注册文件

// app/autoload.php
AnnotationRegistry::registerFile(__DIR__.'/../vendor/doctrine-oxm/lib/Doctrine/OXM/Mapping/Driver/DoctrineAnnotations.php');

最后,在内核中启用新的软件包

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new Doctrine\Bundle\OXMBundle\DoctrineOXMBundle(),
    );

    // ...
}

恭喜!你现在可以开始工作了。

配置

要开始使用,你需要一些基本的配置来设置文档管理器。最简单的方法是启用 auto_mapping,这将激活 OXM 在你的应用程序中

# app/config/config.yml
doctrine_oxm:
    storages:
        default:
            path: "%kernel.root_dir%/doctrine-oxm-storage"

    xml_entity_managers:
        default:
            auto_mapping: true

完整配置

doctrine_oxm:
    proxy_namespace:    Test_Proxies
    auto_generate_proxy_classes:    true
    proxy_dir: "%kernel.cache_dir%/doctrine/oxm/Proxies"


    default_xml_entity_manager:  xem1
    default_storage:             storg1

    storages:
        storg1:
            path: "%kernel.root_dir%/doctrine-oxm-storage/storg1"
        storg2:
            path: "%kernel.root_dir%/doctrine-oxm-storage/storg2"

    xml_entity_managers:
        xem1:
            auto_mapping: false
            mappings:
                FooBundle:   annotations
            metadata_cache_driver: apc
        xem2:
            auto_mapping: false
            storage:         storg2
            mappings:
                BarBundle:
                    type:   yml
                    dir:    %kernel.cache_dir%
                    prefix: prefix_val
                    alias:  alias_val
                    is_bundle: false
            metadata_cache_driver: apc