restate / sdk
Restate SDK for PHP: durable handlers, served through the Restate PHP extension.
Requires
- php: ~8.4.0 || ~8.5.0 || ~8.6.0
- ext-json: *
- ext-restate: ~0.1.0
- psr/container: ^1.1 || ^2.0
- psr/http-factory: ^1.1
- psr/http-message: ^1.1 || ^2.0
- psr/http-server-handler: ^1.0
- psr/log: ^3.0
- restate/common: v0.1.0
Requires (Dev)
None
Suggests
- cuyz/valinor: Required to use the optional Restate\Bridge\Valinor\ValinorJsonPayloadAdapter.
- restate/ingress: Calls Restate services from code that is not a handler.
- restate/testing: Runs Restate and an endpoint for integration tests; install it with --dev.
- symfony/property-access: Useful for standalone Symfony ObjectNormalizer DTO hydration with Restate\Bridge\Symfony\SymfonyJsonPayloadAdapter.
- symfony/property-info: Useful for standalone Symfony ObjectNormalizer type extraction with Restate\Bridge\Symfony\SymfonyJsonPayloadAdapter.
- symfony/serializer: Required to use the optional Restate\Bridge\Symfony\SymfonyJsonPayloadAdapter.
Provides
None
Conflicts
None
Replaces
None
README
Build Restate services in PHP: handlers whose calls, side effects, state, timers and promises Restate journals, so they run to completion across failures and restarts. restate/sdk is the package you serve with: Services, Virtual Objects and Workflows as attributed PHP classes or builders, the handler contexts, and the endpoint that serves them under php -S, PHP-FPM, FrankenPHP or any PSR-15 framework. All Restate traffic goes through the Restate PHP extension, which embeds restate-sdk-shared-core, the core of the official TypeScript, Python and Rust SDKs.
Note
A community-maintained SDK: not an official Restate SDK, and not supported by Restate.
Installation
pie install restate/ext-restate composer require restate/sdk
The package requires the extension (ext-restate) of its own minor version, so Composer refuses to install it without; PIE installs a prebuilt binary (restate/ext-restate).
Usage
<?php require __DIR__ . '/vendor/autoload.php'; use Restate\Attributes as Restate; use Restate\Context; use Restate\Endpoint; #[Restate\Service('Greeter')] final class Greeter { #[Restate\Handler] public function greet(Context $ctx, string $name): string { return "Hello {$name}"; } } Endpoint::serve([new Greeter()]);
The Docker quickstart runs a service like this one with a Restate server and walks through calling it, failing it and killing it mid-request; the serving guide covers PHP-FPM, FrankenPHP and PSR-15.
Related packages: restate/ingress (call services from code that is not a handler), restate/testing (test harness).
Requirements
- PHP 8.4, 8.5 or 8.6, NTS or ZTS
- The Restate PHP extension,
ext-restate - Restate Server 1.8 or newer
Documentation
See the documentation: installation, writing services, serving and testing.
This repository is a read-only subtree split of restate-php/restate. Report issues and send pull requests there.
License
MIT; see LICENSE.