combodo / itop-client-bundle
symfony的iTop rest客户端组件
2.1.0
2022-04-26 12:02 UTC
Requires
- php: ^7.1|^8
- guzzlehttp/guzzle: >=6.3
- mtdowling/jmespath.php: >=2.4
- symfony/framework-bundle: 4.4.* || 5.*
Requires (Dev)
- phpmd/phpmd: ^2.6
- phpunit/phpunit: ^7
- squizlabs/php_codesniffer: ^3.3
Conflicts
- symfony/symfony: <=3
This package is not auto-updated.
Last update: 2024-09-25 05:28:02 UTC
README
symfony的iTop rest客户端组件
此组件帮助您消费iTop rest webservices
安装
步骤 1:下载组件
打开命令行,进入您的项目目录,并执行以下命令以下载此组件的最新稳定版本
$ composer require combodo/itop-client-bundle
此命令要求您已全局安装Composer,如Composer文档中的安装章节所述。
步骤 2:配置itop服务器
# app/config/config.yml combodo_itop_client: servers: itop_server_foo: base_url: "%it_combodo.base_url%" auth_user: "%it_combodo.auth_user%" auth_pwd: "%it_combodo.auth_pwd%" extra_headers: "%it_combodo.extra_headers%"
此组件将创建一个名为itop_client.rest_client.itop_server_foo
的服务,您可以在代码中使用此服务。
步骤 3:开始使用
每个操作都遵循在otop文档中提供的结构:遵循以下结构:https://www.itophub.io/wiki/page?id=latest%3Aadvancedtopics%3Arest_json#operationcore_create
您可以使用服务容器或通过在服务构造函数中添加Combodo\ItopClientBundle\RestClient\RestClient $foo
来使用服务注入。
use Combodo\ItopClientBundle\RestClient\RequestOperation\Core\RequestOperationCoreCreate; use Combodo\ItopClientBundle\RestClient\RestClient; class Foo { /** * @var RestClient */ private $client; public function __construct(RestClient $client) { $this->client = $client; } public function bar() { $operation = new RequestOperationCoreCreate( 'Class', 'id', 'my comment', [ 'title' => 'foo', 'description' => 'bar', 'caller_email' => 'boris.vian@example.com', ] ); $this->client->executeOperation($operation); } }