setono / post-nord-bundle
集成了 PostNord PHP SDK 的 Symfony 扩展包
v2.0.0-alpha
2024-06-10 09:44 UTC
Requires
- php: >=8.1
- setono/post-nord-php-sdk: ^2.0@alpha
- symfony/config: ^5.4 || ^6.4 || ^7.0
- symfony/dependency-injection: ^5.4 || ^6.4 || ^7.0
- symfony/http-kernel: ^5.4 || ^6.4 || ^7.0
Requires (Dev)
- infection/infection: ^0.27.11
- matthiasnoback/symfony-config-test: ^4.3 || ^5.1
- matthiasnoback/symfony-dependency-injection-test: ^4.3 || ^5.1
- nyholm/psr7: ^1.1
- phpunit/phpunit: ^9.6
- psalm/plugin-phpunit: ^0.19.0
- setono/code-quality-pack: ^2.7.2
- symfony/http-client: ^5.4 || ^6.4 || ^7.0
This package is auto-updated.
Last update: 2024-09-10 10:34:52 UTC
README
将 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>