https://github.com/heyjorgedev/qstash-php
QStash SDK for PHP - QStash is an HTTP based messaging and scheduling solution for serverless and edge runtimes.
https://github.com/heyjorgedev/qstash-php
php qstash queue scheduler upstash upstash-qstash
Last synced: 5 months ago
JSON representation
QStash SDK for PHP - QStash is an HTTP based messaging and scheduling solution for serverless and edge runtimes.
- Host: GitHub
- URL: https://github.com/heyjorgedev/qstash-php
- Owner: heyjorgedev
- License: mit
- Created: 2024-07-12T23:00:22.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-27T12:51:38.000Z (8 months ago)
- Last Synced: 2025-01-27T13:49:40.057Z (8 months ago)
- Topics: php, qstash, queue, scheduler, upstash, upstash-qstash
- Language: PHP
- Homepage:
- Size: 92.8 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
> **This project is still in early stages of development.**
> I am still writing most of the API endpoints and the API is under constant change so I do not recommend to use it on production yet.# QStash Client SDK for PHP
[](https://packagist.org/packages/heyjorgedev/qstash-php)
[](https://github.com/heyjorgedev/qstash-php/actions/workflows/run-tests.yml)
[](https://packagist.org/packages/heyjorgedev/qstash-php)**QStash** is an HTTP based messaging and scheduling solution for serverless and
edge runtimes.## How does QStash work?
QStash is the message broker between your serverless apps. You send an HTTP
request to QStash, that includes a destination, a payload and optional settings.
We durably store your message and will deliver it to the destination API via
HTTP. In case the destination is not ready to receive the message, we will retry
the message later, to guarantee at-least-once delivery.## Installation
You can install the package via composer:
```bash
composer require heyjorgedev/qstash-php
```### Get your authorization token
Go to [Upstash Console](https://console.upstash.com/qstash) and copy the QSTASH_TOKEN.
## Basic Usage
```php
use HeyJorgeDev\QStash\QStash;
use HeyJorgeDev\QStash\ValueObjects\Message;
use HeyJorgeDev\QStash\ValueObjects\Url;$client = QStash::client('QSTASH_TOKEN');
$message = $client->publish(
Message::to(new Url('https://my-api...'))
->withBody([
'hello' => 'world',
])
]);// to know if the request was successful:
echo $message->isSuccessful()// to get the message
echo $message->getData();// to get the message id
echo $message->getData()->id;
```## Receiver
When receiving a message from QStash, you should [verify the signature](https://upstash.com/docs/qstash/howto/signature). We have a class to help you with that:```php
use HeyJorgeDev\QStash\QStash;$receiver = QStash::receiver([
'QSTASH_CURRENT_SIGNING_KEY',
'QSTASH_NEXT_SIGNING_KEY',
]);$result = $receiver->verify(
body: $request->getBody(),
signature: $request->getHeader('Upstash-Signature'),
url: $request->getUri(),
);echo $result; // true or false
```
## Testing```bash
composer test
```## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Jorge Lapa](https://github.com/heyjorgedev)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.