fei / api-client
Client side API helpers
Installs: 15 031
Dependents: 9
Suggesters: 0
Security: 0
Stars: 0
Watchers: 25
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
- ext-json: *
- fei/entities: ^1.3
- guzzlehttp/guzzle: ^6.3
- pda/pheanstalk: ^3.2
Requires (Dev)
- dev-master
- v2.0.0
- v1.5.1
- v1.5.0
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.1
- v1.3.0
- v1.2.7
- v1.2.6
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1.x-dev
- v1.2.1
- v1.2.0
- v1.1.9
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-update/composer
- dev-detached
- dev-detached2
- dev-hotfix/improve_log_upon_filer_upload_failure
This package is not auto-updated.
Last update: 2024-11-24 06:04:00 UTC
README
Low level API client.
All API client should use this library and extend \Fei\ApiClient\AbstractApiClient
abstract class.
Installation
Use Composer: composer.phar require fei/mailer-client
Or add this requirement "fei/api-client": "^1.1.0"
to your composer.json
file.
Use the BeanstalkProxyWorker
The BeanstalkProxyWorker
is used for consume Beanstalkd messages queue and send them to the targeted api server.
<?php require __DIR__ . '/vendor/autoload.php'; use Fei\ApiClient\Transport\BasicTransport; use Fei\ApiClient\Worker\BeanstalkProxyWorker; use Pheanstalk\Pheanstalk; use Pheanstalk\PheanstalkInterface; $host = "127.0.0.1"; $port = PheanstalkInterface::DEFAULT_PORT; $worker = new BeanstalkProxyWorker(); $worker->setPheanstalk(new Pheanstalk($host, $port)); $worker->setTransport(new BasicTransport()); $worker->run(BeanstalkProxyWorker::VERBOSE);
This example will consume one message from Beanstakld tube (or queue) and send it to the api server.
For handle more messages you should create a infinite loop !
<?php require __DIR__ . '/vendor/autoload.php'; use Fei\ApiClient\Transport\BasicTransport; use Fei\ApiClient\Worker\BeanstalkProxyWorker; use Pheanstalk\Pheanstalk; use Pheanstalk\PheanstalkInterface; $host = "127.0.0.1"; $port = PheanstalkInterface::DEFAULT_PORT; $worker = new BeanstalkProxyWorker(); $worker->setPheanstalk(new Pheanstalk($host, $port)); $worker->setTransport(new BasicTransport()); while (true) { $worker->run(BeanstalkProxyWorker::VERBOSE); }
For a reliable worker, please use script/api-client-worker.php
:
api-client-worker.php -h 127.0.0.1 -p 11300 -d 5