Download the PHP package robo-meister/context-engine-api without Composer

On this page you can find all versions of the php package robo-meister/context-engine-api. 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 context-engine-api

Context Engine PHP SDK

PHP 8.1+ client for the scoped Context Engine API introduced by CE-CONTRACT-TRANSPORT-PARITY-001 (CE PR #144). The canonical application client uses HTTP. An optional Redis request/reply helper remains available.

Installation

Requires PHP 8.1+, ext-curl and ext-json. The Composer package name stays robo-meister/context-engine-api; this change does not create a release tag.

For a local checkout, add this to your application's composer.json:

Then run composer update robo-meister/context-engine-api and load vendor/autoload.php. For direct installation copy all four root PHP files, including ContextEngineException.php and ScopedContextClientInterface.php, then require_once 'ContextEngineClient.php' (and the Redis client if used).

Scoped API

Method HTTP operation Result
resolve(keys, scopeRefs) POST /resolve values, provenance, missingKeys
getScopedContext(scopeType, scopeId, keys, store, kind) POST /scopes/{type}/{id}/get values, metadata, missingKeys
setDefaultContext(scopeType, scopeId, values, updatedBy) PATCH /scopes/{type}/{id}/default status: ok
setActiveContext(scopeType, scopeId, values, kind, ttl, updatedBy) PATCH /scopes/{type}/{id}/active status: ok
unsetContext(scopeType, scopeId, keys, store, kind) POST /scopes/{type}/{id}/unset status: ok

One resolve call sends one request for all supplied keys. The SDK preserves scope order; CE checks each scope's active STATE, active CACHE, then default, before moving to the next scope. It neither expands dependencies nor implements a local resolver. With active, omitted kind reads STATE then CACHE; on unset it removes both kinds. With default, kind is not accepted.

TTL is a positive integer in seconds. null omits TTL; default has no TTL parameter. Version, scopeRef, store, kind, updatedBy, updatedAt, ttlSeconds and expiresAt are returned as supplied by CE. Optional fields stay optional, and unknown metadata fields are preserved. Server timestamps are epoch milliseconds. Version increases for an existing record; it can restart after expiry or deletion. The SDK does not manufacture a version or renew expiry on read.

Results are associative PHP arrays. JSON objects decode to arrays, and JSON integers beyond the platform integer range decode to strings. Use array_key_exists to distinguish an explicit null value from a missing key; false, zero and empty strings remain values. Mutations return acknowledgements, not the new metadata. Read explicitly when an application needs the resulting version or preview.

Authentication and failures

The existing constructor's first four parameters are unchanged. For a gateway using bearer authentication, supply bearerToken instead of apiKey:

HTTPS is required by default. For an explicitly trusted local endpoint use new ContextEngineClient('http://localhost:8080', timeout: 8, enforceHttps: false). Certificate verification stays enabled for HTTPS, and redirects are never followed. The SDK does not exchange OAuth tokens or infer account/subscription permissions. Scope selection and updatedBy are data, not proof of authority: your trusted application/gateway must enforce access. CE PR #144's WebServer does not itself validate these authentication headers.

Scoped failures use invalid_request, transport_error, http_error, invalid_json or invalid_response. HTTP failures preserve status, body and headers, but the default exception message excludes the body and credentials. Existing RuntimeException catches still work; constructor configuration errors remain RuntimeException. There is no automatic retry, fallback transport, or missing-context substitution on a failed request. In particular, CE HTTP writes do not expose mutation idempotency keys: a timeout can leave their outcome unknown.

Compatibility and server limits

getContext, upsertContext, deleteContext and searchContext retain their signatures and legacy /context routes. That facade uses ce:context:* and does not expose canonical scoped records from events. RC must explicitly migrate its context reads to the scoped API; installing this SDK alone does not switch them.

The scoped client targets CE 12683d8051314334cae234968a38accfbf2b5456 (main after PR #144). Current server limitations are made explicit:

These constraints need server-side follow-up before the SDK can relax them. This PR does not claim full RC/event-mapper interoperability or fix server lifecycle.

Optional Redis request/reply

This is the existing Pub/Sub control bridge, not the durable event stream. It requires a running CE RedisRequestListener and a caller-supplied Redis client configured without transparent serialization. sendRequest(..., true) returns the bridge envelope (status, JSON-string body, request_id), not the scoped HTTP client's result. HTTP status errors inside that envelope must be checked.

The control bridge is for trusted internal Redis clients. The current server bridge does not forward SDK HTTP authentication headers. Redis connection/auth/ACL configuration remains owned by the application and infrastructure.

waitForResponse: false returns the request ID after publish; it does not prove that a listener received the request or that context was updated. Pub/Sub does not queue messages for disconnected listeners. No automatic retry is performed. Both false (phpredis) and null (other clients) mean a reply key is still absent.

Defaults remain context_engine:requests, context_engine:response: and context_engine:greeting. The helper rejects CE stream/state key namespaces (including ce:events) for its request/reply/greeting configuration. If the stream has a custom name, pass that name as eventsStreamKey too. There is no SET operation on the event stream, no key deletion to repair a wrong type, and no implicit direct read of CE state keys.

For applications using the optional PHP handleRequests worker, a separate responseWriter Redis connection is now required. Subscribed connections cannot safely write responses. The worker writes JSON via SETEX with responseTtlSeconds (default 300), and only accepts reply keys with its configured prefix plus the SDK's 16-character hex request ID. Other request-ID formats need an explicit application adapter. Validate/authenticate business payloads in your handler. Existing calls to sendRequest do not need a response writer.

Verification

Runs legacy constructor checks, local HTTP contract tests, and Redis helper tests. The HTTP fixture starts on a random loopback port; normal tests need neither a CE server nor a Redis extension/server. They cover request count and scope order, PATCH payloads, metadata, typed values, errors, no retry/redirect, and reserved keys.

For a disposable local CE + Redis instance matching the server commit above, with its stream consumer and request listener enabled, additionally run:

This requires ext-redis and creates randomized test scopes, stream entries, checkpoints and replay markers. Run only against a disposable local instance. It checks scoped CRUD, resolver precedence, expiry, metadata, bridge PATCH and HTTP parity, event projection visible via /resolve, and replay preserving version/TTL. It does not flush Redis. Stream history/markers remain for disposal with the test instance.


All versions of context-engine-api with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-curl Version *
ext-json Version *
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 robo-meister/context-engine-api contains the following files

Loading the files please wait ...