PHPackages                             elytica/compute-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. elytica/compute-client

ActiveLibrary[API Development](/categories/api)

elytica/compute-client
======================

PHP implementation for the elytica Compute API.

v0.4.2(2mo ago)11.0k↓54.7%[1 PRs](https://github.com/elytica/compute-client/pulls)MITPHPPHP ^8.2CI passing

Since Feb 20Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/elytica/compute-client)[ Packagist](https://packagist.org/packages/elytica/compute-client)[ RSS](/packages/elytica-compute-client/feed)WikiDiscussions main Synced yesterday

READMEChangelog (6)Dependencies (13)Versions (17)Used By (0)

compute-client
==============

[](#compute-client)

PHP client for the [elytica](https://elytica.com) Compute API. Ships as a plain PHP library and as a Laravel package (auto-discovered service provider and publishable config).

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11, 12, or 13 (Laravel 13 requires PHP 8.3+)
- ext-json, ext-mbstring

Installation
------------

[](#installation)

```
composer require elytica/compute-client
```

Configuration
-------------

[](#configuration)

The client reads two values: an API token and a base URL.

### Laravel

[](#laravel)

The service provider is registered automatically. Publish the config if you want to edit it directly:

```
php artisan vendor:publish --tag=compute-config
```

Then set the credentials in `.env`:

```
COMPUTE_TOKEN=your-api-token
COMPUTE_BASE_URL=https://service.elytica.com
```

Resolve the service from the container:

```
use Elytica\ComputeClient\ComputeService;

$compute = app(ComputeService::class);
echo $compute->getUserName();
```

### Standalone (no Laravel)

[](#standalone-no-laravel)

Construct the service directly with the token and base URL:

```
use Elytica\ComputeClient\ComputeService;

$compute = new ComputeService(
    token: 'your-api-token',
    base_url: 'https://service.elytica.com',
);
```

The constructor calls `whoami()` and throws `RuntimeException` if authentication fails.

Usage
-----

[](#usage)

### User and applications

[](#user-and-applications)

```
$compute->getUserId();         // int
$compute->getUserName();       // string
$compute->whoami();            // raw user object
$compute->getApplications();   // available compute applications
```

### Projects

[](#projects)

```
$projects = $compute->getProjects();

$project = $compute->createNewProject(
    project_name:        'My project',
    project_description: 'Optimization run for X',
    application:         $applicationId,
    webhook_url:         'https://example.com/webhooks/compute', // optional
    webhook_secret:      'shared-secret',                         // optional
);

$compute->updateProject(
    project_id:   $project->id,
    description:  'Updated description',
);

$compute->deleteProject($project->id);
```

### Jobs

[](#jobs)

```
$job = $compute->createNewJob($project->id, 'Job 1', priority: 100);

// Upload an input file and assign it to the job
$upload = $compute->uploadInputFile(
    filename:   'model.lp',
    contents:   file_get_contents('/path/to/model.lp'),
    project_id: $project->id,
);

$compute->assignFileToJob(
    project_id: $project->id,
    job_id:     $job->id,
    file_id:    $upload[0]->id,
    arg:        1,
);

// Queue the job for execution
$compute->queueJob($job->id);

// Halt a running job
$compute->haltJob($job->id);
```

### Files

[](#files)

```
$inputs  = $compute->getInputFiles($project->id);
$outputs = $compute->getOutputFiles($job->id, $project->id);

// Stream a file to disk
$compute->downloadFile($project->id, $fileId, '/tmp/result.csv');
```

### Job status constants

[](#job-status-constants)

`Elytica\ComputeClient\JobStatus` exposes the lifecycle states:

ConstantValueMeaning`RESET`0Created, not yet queued`QUEUED`1Waiting to be picked up`ACCEPT`2Accepted by a worker`PROCESS`3Running`COMPLETED`4Finished successfully`HALTED`5Halted (manually or on error)`Elytica\ComputeClient\JobFailureReason` enumerates failure causes (`OUT_OF_MEMORY`, `SERVER_BUSY`, `DOWNLOAD_FAILED`, `PROCESS_CRASHED`, `WEBSOCKET_BROKEN`, `TIMEOUT`, `INVALID_JOB`).

V2 API
------

[](#v2-api)

The V2 endpoints reduce round-trips for common workflows.

### Consolidated user context

[](#consolidated-user-context)

Returns user, applications, projects, and subscription in one call:

```
$context = $compute->getUserContext();
```

### Batch job status

[](#batch-job-status)

```
$statuses = $compute->getJobBatchStatus([101, 102, 103]);
```

### Batch halt

[](#batch-halt)

```
$compute->haltJobs([101, 102, 103]);
```

### Atomic project + jobs

[](#atomic-project--jobs)

Create a project and its jobs in a single request:

```
$workflow = $compute->createProjectWorkflow(
    projectName:        'Daily run',
    projectDescription: 'Scheduled batch',
    application:        $applicationId,
    jobs: [
        ['name' => 'Job A', 'priority' => 100],
        ['name' => 'Job B', 'priority' => 50],
    ],
    webhookUrl:    'https://example.com/webhooks/compute',
    webhookSecret: 'shared-secret',
);
```

### Webhook signature verification

[](#webhook-signature-verification)

Webhooks are signed with HMAC-SHA256 using the project's `webhook_secret`. Verify the signature on the receiving side before trusting the payload:

```
use Elytica\ComputeClient\ComputeService;

$raw       = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_SIGNATURE'] ?? '';

if (! ComputeService::verifyWebhookSignature($raw, $signature, $secret)) {
    http_response_code(401);
    exit;
}

$payload = json_decode($raw);
// ... handle event
```

Error handling
--------------

[](#error-handling)

Most write methods accept an optional `$error_callback` invoked with the caught exception. The method returns `null` on failure:

```
$result = $compute->queueJob($job->id, function (\Throwable $e) {
    report($e);
});

if ($result === null) {
    // request failed; callback already received the exception
}
```

If you omit the callback, failures are swallowed silently and the method returns `null` — pass a callback (or wrap the call yourself) when you need to react to errors.

WebSocket client
----------------

[](#websocket-client)

`Elytica\ComputeClient\WebsocketClient` connects to the elytica realtime channel (Pusher protocol via Ratchet) and is useful for streaming job progress events:

```
use Elytica\ComputeClient\WebsocketClient;

$ws = new WebsocketClient(
    auth_url: 'https://service.elytica.com/broadcasting/auth',
    ws_url:   'wss://ws.elytica.com:443',
    app_key:  $appKey,
    app_id:   $appId,
    token:    $token,
    timeout:  10,
);

$ws->addInitChannel("private-job.$jobId");

$ws->connect(function ($message, $conn) use ($ws) {
    // handle event
    if ($message->event === 'job.completed') {
        $ws->stop();
    }
});
```

Testing
-------

[](#testing)

```
composer install
./vendor/bin/phpunit --testsuite unit
```

The test suite is matrixed across PHP 8.2 / 8.3 and Laravel 11 / 12 / 13 in CI (`.github/workflows/tests.yml`). The PHP 8.2 + Laravel 13 cell is excluded because Laravel 13 requires PHP 8.3+.

License
-------

[](#license)

MIT — see `composer.json` for author details.

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance87

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~83 days

Recently: every ~210 days

Total

15

Last Release

65d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/63094025?v=4)[elytica](/maintainers/elytica)[@elytica](https://github.com/elytica)

---

Top Contributors

[![Baggins800](https://avatars.githubusercontent.com/u/10725942?v=4)](https://github.com/Baggins800 "Baggins800 (100 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

elyticainteger-programming

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/elytica-compute-client/health.svg)

```
[![Health](https://phpackages.com/badges/elytica-compute-client/health.svg)](https://phpackages.com/packages/elytica-compute-client)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M130](/packages/roots-acorn)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[flat3/lodata

OData v4.01 Producer for Laravel

99351.7k](/packages/flat3-lodata)[showdoc/showdoc

ShowDoc is a tool greatly applicable for an IT team to share documents online

12.8k7.1k](/packages/showdoc-showdoc)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
