Download the PHP package ruudk/absurd-php-sdk without Composer

On this page you can find all versions of the php package ruudk/absurd-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package absurd-php-sdk

Absurd SDK for PHP

PHP SDK for Absurd: a PostgreSQL-based durable task execution system.

Absurd is the simplest durable execution workflow system you can think of. It's entirely based on Postgres and nothing else. It's almost as easy to use as a queue, but it handles scheduling and retries, and it does all of that without needing any other services to run in addition to Postgres.

Note: This PHP SDK is still in its early stages. Absurd itself has been running in production at Earendil since its initial release.

What is Durable Execution?

Durable execution (or durable workflows) is a way to run long-lived, reliable functions that can survive crashes, restarts, and network failures without losing state or duplicating work. Instead of running your logic in memory, a durable execution system decomposes a task into smaller pieces (step functions) and records every step and decision.

How It Works

This SDK uses PHP Fibers to provide a clean, synchronous-looking API for durable workflows. When you call methods like $ctx->step(), $ctx->awaitEvent(), or $ctx->sleepFor(), the Fiber suspends execution, allowing the SDK to checkpoint progress to the database. When the task resumes (after a crash, timeout, or event), execution continues from exactly where it left off.

This means you can write workflow code that looks like normal sequential PHP code, while the SDK handles all the complexity of persistence, retries, and resumption behind the scenes.

Installation

Quick Start

Client Configuration

The Absurd constructor accepts a Connection instance instead of a raw PDO object. Wrap your PDO with PdoConnection (or implement your own adapter, e.g. for Doctrine DBAL):

The serializer defaults to JsonSerializer (no extra dependencies). Pass SymfonySerializer if you need typed object deserialization:

Custom Database Connection

Implement Connection\Connection to integrate with any database layer (e.g. Doctrine DBAL):

Queue Management

Task Registration

Spawning Tasks

Retry Strategies

Task Context Methods

Inside a task handler, you have access to TaskContext with these methods:

Emitting Events

Cancelling Tasks

Running tasks will stop at their next checkpoint, heartbeat, or await event call.

Retrying Tasks

Force a retry of a failed or cancelled task:

Use the BeforeRetryEvent to modify retry options from a listener (same pattern as BeforeSpawnEvent).

Retrieving Task Info

Worker Configuration

Worker Concurrency Model

PHP workers process tasks sequentially within a single process. The batchSize option controls how many tasks are claimed from the database in each poll, but they are still executed one at a time. This design ensures:

For concurrent task processing, run multiple worker processes:

Or use a process manager like Supervisor:

Events

Use a PSR-14 EventDispatcherInterface for lifecycle hooks and error handling.

Available Events

Event Dispatched when
WorkerStartedEvent Worker begins polling
WorkerStoppedEvent Worker stops
WorkerRunningEvent After each poll cycle (idle or after batch completion)
TaskStartedEvent A task is picked up for execution
TaskCompletedEvent A task finishes (includes suspended tasks)
TaskFailedEvent A task throws an unhandled exception
TaskErrorEvent Any error occurs (task or worker level)
BeforeSpawnEvent Before a task is spawned (options are mutable)
BeforeRetryEvent Before a task is retried (options are mutable)
TaskExecutionEvent Wraps task execution (for context propagation)

Typed Payloads

With a serializer that supports type hydration (like the shipped SymfonySerializer), you can use typed objects as task parameters:

Idempotency Keys

Use idempotency keys to prevent duplicate task creation:

Use task ID for deriving idempotency keys for external APIs:

Local Development

Prerequisites

Quick Start

After running make up:

Running the Examples

The SDK includes two comprehensive examples:

E-commerce Order Fulfillment

Demonstrates checkpoints, events, sub-tasks, and trace propagation in a realistic order processing scenario.

AI Agent with Tool Calling

Demonstrates a durable AI agent workflow based on this blog post. The agent loops through conversation steps, calling tools as needed, with each iteration durably checkpointed.

Features:

Make Commands

Command Description
make help Show available commands
make setup Download absurdctl binary
make up Start PostgreSQL, initialize Absurd, and run Habitat
make down Stop containers
make clean Remove binaries and database volumes

Production Setup

For production, initialize Absurd in your PostgreSQL database:

API Reference

Absurd Class

Method Description
registerTask(name, handler, options?) Register a task handler
spawn(taskName, params, options?, queue?) Spawn a new task
retryTask(taskId, options?, queue?) Retry a failed or cancelled task
getTask(taskId, queueName?) Get task info by ID
emitEvent(eventName, payload?, queueName?) Emit an event
cancelTask(taskId, queueName?) Cancel a running task
claimTasks(options?) Claim tasks for processing
startWorker(options?) Start a worker
createQueue(queueName?) Create a queue
dropQueue(queueName?) Drop a queue
listQueues() List all queues
executeTask(task, claimTimeout, ...) Execute a claimed task

TaskContext Class

Method Description
step(name, value) Execute a checkpointed step
beginStep(name) Begin a split step, returns a StepHandle
completeStep(handle, value) Complete a split step, returns the value (cached on replay)
awaitEvent(eventName, options?) Wait for an event
sleepFor(stepName, duration) Sleep for a duration (seconds)
sleepUntil(stepName, wakeAt) Sleep until a specific time
emitEvent(eventName, payload?) Emit an event from within a task
heartbeat(seconds?) Extend the task lease

SpawnResult Class

Property Type Description
taskId string Unique task identifier
runId string Current run identifier
attempt int Current attempt number
created bool True if newly created, false if from idempotency cache

All versions of absurd-php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
ext-pdo Version *
psr/event-dispatcher Version ^1.0
psr/log Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ruudk/absurd-php-sdk contains the following files

Loading the files please wait ...