承接 updevru/dkron-php-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

updevru/dkron-php-client

最新稳定版本:v1.2

Composer 安装命令:

composer require updevru/dkron-php-client

包简介

README 文档

README

Build Status Latest stable PHP from Packagist

This is the PHP Dkron API client. This library allows using of the actual API version. You can find more info in the documentation.

Table of contents

Requirements

  • PHP 7.4 and above
  • PHP's cURL support
  • PHP's JSON support
  • Any HTTP client compatible with PSR-18 (covered by the installation instructions).
  • Any HTTP factories implementation compatible with PSR-17 (covered by the installation instructions).
  • Any HTTP messages implementation compatible with PSR-7 (covered by the installation instructions).

Installation

Install the library from the Packagist by executing this command:

composer require updevru/dkron-php-client

Note: API client uses php-http/curl-client and nyholm/psr7 as a PSR-18, PSR-17 and PSR-7 implementation. You can replace those implementations during installation by installing this library with the implementation of your choice, like this:

composer require php-http/curl-client nyholm/psr7 updevru/dkron-php-client

Usage

Firstly, you should initialize the Client.

use Http\Client\Curl\Client;
use Nyholm\Psr7\Factory\Psr17Factory;
use Updevru\Dkron\ApiClient;
use Updevru\Dkron\Endpoint\EndpointCollection;

$client = new Updevru\Dkron\ApiClient(
    new Updevru\Dkron\Endpoint\EndpointCollection(
        [
            [
                'url' => 'http://localhost',
                'login' => null,
                'password' => null,
            ]
        ]
    ),
    new Http\Client\Curl\Client(),
    new Nyholm\Psr7\Factory\Psr17Factory(),
    new Nyholm\Psr7\Factory\Psr17Factory()
);

$api = new \Updevru\Dkron\Api($client, new \Updevru\Dkron\Serializer\JMSSerializer());

If HTTP basic authorization is enabled, enter login and password.

Create new job:

$newJob = new \Updevru\Dkron\Dto\JobDto();
$newJob->setName('test_job');
$newJob->setSchedule('*/2 * * * * *');
$newJob->setConcurrency(\Updevru\Dkron\Dto\JobDto::CONCURRENCY_FORBID);
$newJob->setExecutor('shell');
$newJob->setExecutorConfig(['command' => 'echo Hello']);

$api->jobs->createOrUpdateJob($newJob);

Run job manually:

$api->jobs->runJob('test_job');

Show list executions:

$jobs = $api->jobs->getJobs();

Disable job:

$api->jobs->toggleJob('test_job');

Deleting job test_job:

$api->jobs->deleteJob('test_job');

Testing

Run unit tests:

composer tests

Demo working library:

php bin/test.php http://localhost:8080

统计信息

  • 总下载量: 2.2k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-12