setono/dao-bundle

Symfony 扩展包,集成了 DAO PHP SDK

安装数: 21,654

依赖者: 3

推荐者: 3

安全: 0

星标: 1

关注者: 3

分支: 0

公开问题: 6

类型:symfony-bundle


README

Latest Version Latest Unstable Version Software License Build Status Quality Score

DAO PHP SDK 集成到 Symfony。

安装

步骤 1: 下载扩展包

打开命令行,进入项目目录并执行以下命令以下载此插件的最新稳定版本

$ composer require setono/dao-bundle

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

步骤 2: 启用扩展包

通过将其添加到 config/bundles.php 中的已注册插件/扩展包列表中来启用插件

<?php
$bundles = [
    // ...
    
    Setono\DAOBundle\SetonoDAOBundle::class => ['all' => true],
    
    // ...
];

使用方法

现在您可以将 ClientInterface 注入到您的服务中

<?php

use Setono\DAO\Client\ClientInterface;

final class YourService
{
    private $client;
    
    public function __construct(ClientInterface $client)
    {
        $this->client = $client;
    }
}

使用自动绑定,这会自动完成。如果您没有使用自动绑定,您必须在服务定义中注入它

<?xml version="1.0" encoding="UTF-8" ?>

<container xmlns="https://symfony.com.cn/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://symfony.com.cn/schema/dic/services https://symfony.com.cn/schema/dic/services/services-1.0.xsd">
    <services>
        <service id="YourService">
            <argument type="service" id="Setono\DAO\Client\ClientInterface"/>
        </service>
    </services>
</container>