setono/post-nord-bundle

集成了 PostNord PHP SDK 的 Symfony 扩展包

资助包维护!
Setono

安装数: 22,342

依赖者: 3

建议者: 3

安全: 0

星标: 0

关注者: 2

分支: 0

公开问题: 0

类型:symfony-bundle

v2.0.0-alpha 2024-06-10 09:44 UTC

This package is auto-updated.

Last update: 2024-09-10 10:34:52 UTC


README

Latest Version Software License Build Status Code Coverage Mutation testing

PostNord PHP SDK 集成到 Symfony。

安装

步骤 1: 下载扩展包

composer require setono/post-nord-bundle

步骤 2: 启用扩展包

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

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

使用

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

<?php

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