setono / gls-webservice-bundle

Symfony 扩展包,集成了 GLS webservice PHP SDK

安装次数: 42,404

依赖者: 3

建议者: 3

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 1

类型:symfony-bundle

v1.3.0 2022-10-11 09:54 UTC

This package is auto-updated.

Last update: 2024-08-29 04:49:05 UTC


README

Latest Version Software License Build Status

GLS webservice PHP SDK 集成到 Symfony。

安装

步骤 1: 下载扩展包

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

$ composer require setono/gls-webservice-bundle

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

步骤 2: 启用扩展包

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

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

使用方法

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

<?php

use Setono\GLS\Webservice\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\GLS\Webservice\Client\ClientInterface"/>
        </service>
    </services>
</container>