shapecode/repository-as-a-service

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

Symfony2 Bundle,可以轻松注册仓库。

2.0.0 2018-06-12 13:14 UTC

README

SensioLabsInsight Dependency Status Latest Stable Version Total Downloads License

此包允许将仓库注册为服务。

安装说明

通过以下简单步骤安装此包

将包添加到项目的composer依赖中

// composer.json
{
    // ...
    require: {
        // ...
        "shapecode/repository-as-a-service": "~1.2"
    }
}

更新您的composer安装

$ composer update

将包添加到您的应用程序内核中

<?php

// application/ApplicationKernel.php
public function registerBundles()
{
	// ...
	$bundle = array(
		// ...
        new Shapecode\Bundle\RasSBundle\ShapecodeRasSBundle(),
	);
    // ...

    return $bundles;
}

开始使用该包并将仓库设置为服务

app.repository.example:
    class: %app.repository.example.class%
    tags:
        -  { name: doctrine.repository, class: %app.entity.example.class%, alias: example_repository }

或者让包为您完成工作。它将自动为您创建服务。只需使用 "lowercaseentitnyname_repository" 访问即可。

<?php

$this->getContainer()->get('lowercaseentitnyname_repository');

也支持旧的方式获取仓库。如果您这样获取...

<?php

$this->getRepository('ShapecodeRasSBundle:TestEntity');

...那么您将直接从仓库获取服务。