trego/toolkit

Trego 基于PHP服务的工具包

dev-master 2019-01-26 10:57 UTC

This package is not auto-updated.

Last update: 2024-09-25 09:32:57 UTC


README

为Trego基于PHP服务的工具包。

如何使用

第一次使用 Toolkit 时,不要忘记通过这种方式构造对象:

$toolkit = new Toolkit([
    'aws_access_key' => 'your_access_key',
    'aws_secret_key' => 'your_secret_key',
])

功能

  • Amazon Web Services DynamoDB
  • Amazon Web Services Simple Queue Services

Amazon Web Services DynamoDB

要获取存储在 DynamoDB 中的配置键,你可能需要输入以下内容:

$toolkit = $toolkit->getConfig('configuration_key');

Amazon Web Services Simple Queue Services

要将消息发送到队列中,你可能需要使用 dispatch() 方法,如下所示:

$result = $toolkit->dispatch('queue_name', $payload);

请确保 queue_name 已经在 AWS DynamoDB 中注册。对于有效负载属性,请确保在使用 dispatch 方法之前使用 json_encode。

要从队列中接收消息,你可能需要使用 listen() 方法,如下所示:

$result = $toolkit->listen('queue_name', function ($message) {
    // The process goes here.
});