Download the PHP package sikkerkey/sdk without Composer

On this page you can find all versions of the php package sikkerkey/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 sdk

SikkerKey PHP SDK

Packagist PHP

Use the official SikkerKey PHP SDK to give a PHP application read access to the secrets its machine is authorized to use.

The SDK can:

After the client is initialized, every secret request is authenticated with the machine's Ed25519 identity. The SDK supports PHP 8.1 or newer and has no third-party Composer package dependencies.

Requirements

Install the SDK

Read your first secret

The SDK loads the machine identity from:

It signs the request with the machine's Ed25519 private key and returns the secret value as a string. Your application's access remains limited by the machine's configured access.

All SDK calls are synchronous.

Create a client

When no argument is supplied, the SDK checks SIKKERKEY_IDENTITY first. If that variable is not set, it uses the only registered vault under ~/.sikkerkey/vaults/.

If more than one vault is registered, select one explicitly. Missing identities, unreadable keys, invalid identity files, and ambiguous vault selection produce ConfigurationError.

The vault_ prefix is added when a vault ID is supplied without it.

Use a different identity directory

The SDK will look under:

Use an ephemeral identity

SikkerKey::bootstrapInMemory is designed for short-lived or read-only environments where an identity should not be stored on disk.

During bootstrap, the SDK:

  1. Generates an Ed25519 key pair in memory.
  2. Uses the enrollment token to register an ephemeral machine.
  3. Keeps the private key inside the running PHP process.
  4. Returns a client ready to read the secrets allowed by the token's access policy.

Nothing is written to disk. The private key disappears when the process exits.

The enrollment token registers the machine; it does not read secrets itself. The resulting machine remains subject to the token's permitted scope, use limit, hostname rules, and machine lifetime. Reads produce AuthenticationError after the machine expires.

Set the machine hostname and name

hostname defaults to the HOSTNAME environment variable and then to serverless. A name pattern configured on the enrollment token takes precedence over name.

For reliable ephemeral deployments:

Each active ephemeral machine uses a machine slot until it expires.

Read secrets

Standard secrets

Structured secrets

getFields expects a JSON object. Scalar properties become strings; nested values are returned as JSON text. Another structure produces SecretStructureError.

Use getField when the application needs one field:

A missing field produces FieldNotFoundError with the available field names.

Discover accessible secrets

Limit the result to one project:

Each SecretListItem contains:

Property Type Meaning
id string Secret ID used by read methods
name string Display name
fieldNames ?string Optional structured-field metadata
projectId ?string Owning project, when present

Listing returns metadata, not secret values.

Export secrets for application configuration

Limit the export to a project:

The returned array<string,string> uses uppercase environment-style names. Structured secrets are expanded into one entry per field:

You can apply the result to the current process:

Continue reads during temporary outages

The fallback cache is disabled by default:

After it is enabled, successful getSecret reads are stored under:

getFields and getField use getSecret, so their successful reads are cached too. Cache writes are best-effort and cannot turn a successful live read into a failure.

The SDK can return a cached value after a network failure, request timeout, or HTTP 502, 503, 504, 520 through 527, or 530.

Authentication failures, revoked access, missing secrets, rate limits, and other authoritative responses are never replaced by cached values.

Entries use AES-256-GCM with a key derived from the machine's Ed25519 identity and vault ID. Tampered entries and entries belonging to another identity are rejected. The .skc format is compatible with other SikkerKey SDKs and the SikkerKey CLI.

Limit cache age and observe fallback use

maxAge is measured in seconds. Passing null means no automatic expiry. The callback is optional; fallback is otherwise silent.

The cache is intended for a host with a persistent, protected identity directory, not a memory-only identity that disappears with the process.

Work with more than one vault

List locally registered vault IDs:

The returned list is sorted alphabetically.

Inspect the active machine

The identity values are available as read-only properties:

They are also available through methods:

Value Meaning
machineId Machine UUID assigned by SikkerKey
machineName Machine name assigned during provisioning or enrollment
vaultId Vault associated with the identity
apiUrl Service endpoint stored in the identity

Handle errors

Exception reference

Exception When it is used
ConfigurationError Identity, key, vault-selection, or bootstrap configuration is invalid
AuthenticationError HTTP 401
AccessDeniedError HTTP 403
NotFoundError HTTP 404
ConflictError HTTP 409
RateLimitedError HTTP 429
ServerSealedError HTTP 503
ApiError Another HTTP or network error; inspect httpStatus
SecretStructureError getFields or getField received a non-object value
FieldNotFoundError The requested structured field does not exist

Network failures and request timeouts use ApiError with httpStatus === 0.

Retries and timeout

Authenticated secret requests retry network failures and HTTP 429 or 503 responses up to three times. Retries wait 1, 2, and 4 seconds, and every attempt receives a fresh timestamp and nonce.

Connection and total request timeouts are each configured for 15 seconds. Other HTTP responses are returned immediately as their matching exception.

Feature-to-API reference

What you want to do SDK API Result
Create a client from disk SikkerKey::create(vaultOrPath?) SikkerKey
Create an ephemeral client SikkerKey::bootstrapInMemory(vaultId, token, hostname?, name?) SikkerKey
List locally registered vaults SikkerKey::listVaults() string[]
Enable outage fallback enableCache(maxAge?, onFallback?) The same SikkerKey client
Read a standard secret getSecret(secretId) string
Read every structured field getFields(secretId) array<string,string>
Read one structured field getField(secretId, field) string
List accessible secrets listSecrets() SecretListItem[]
List accessible secrets in a project listSecretsByProject(projectId) SecretListItem[]
Export accessible values export(projectId?) array<string,string>

The PHP SDK does not run a background watcher. Applications that need change notifications can refresh values on their own schedule.

Runtime footprint

The SDK uses:

It has no third-party Composer package dependencies.

Documentation

License

The SikkerKey PHP SDK is available under the MIT License.


All versions of sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-sodium Version *
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 sikkerkey/sdk contains the following files

Loading the files please wait ...