跳到内容

安装

编辑此页

步骤 1:下载扩展包

打开命令行终端,进入你的项目目录并执行以下命令来下载此扩展包的最新稳定版本

1
$ composer require doctrine/doctrine-bundle

此命令要求你全局安装 Composer,如 Composer 文档的安装章节所述。

步骤 2:启用扩展包

你的扩展包应该会被 Flex 自动启用。如果你没有使用 Flex,你需要手动启用扩展包,方法是在你项目的 config/bundles.php 文件中添加以下行

1
2
3
4
5
6
7
8
<?php
// config/bundles.php

return [
    // ...
    Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
    // ...
];

如果你的项目中没有 config/bundles.php 文件,很可能你正在使用旧版本的 Symfony。在这种情况下,你应该有一个 app/AppKernel.php 文件。编辑该文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            // ...

            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
        ];

        // ...
    }

    // ...
}
本作品,包括代码示例,基于 Creative Commons BY-SA 3.0 许可协议授权。
目录
    版本