Download the PHP package supashiphq/php-sdk without Composer

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

Supaship PHP SDK

Lightweight, zero-dependency (runtime) client for Supaship feature flags.

Requirements

The repo’s composer.json sets config.platform.php to 7.4.33 so composer.lock stays installable on PHP 7.4 (transitive dev tools). That does not affect apps that composer require this library; only this package’s root install uses it.

Install

Quick start

Configuration

Key Required Description
sdkKey Yes Project SDK key
environment Yes Environment slug (e.g. production)
features Yes Associative array of flag names → fallback values (boolean, array, or null)
context Yes Default evaluation context (scalar values only)
sensitiveContextProperties No List of context keys whose values are hashed with SHA-256 before the request
networkConfig No See below

networkConfig

Key Default Description
featuresAPIUrl https://edge.supaship.com/v1/features Features endpoint
eventsAPIUrl https://edge.supaship.com/v1/events Documented for parity; not used by this minimal client
requestTimeoutMs 10000 Request timeout (milliseconds)
retry enabled: true, maxAttempts: 3, backoff: 1000 Exponential backoff in ms, same as the JS SDK
httpHandler (none) Optional callable(string $url, string $jsonBody): array{statusCode:int, body:string}

Methods

Optional per-request context:

Framework integrations

SupashipClient has no framework-specific code paths: register it once in the container (or a bootstrap file), inject it where you need flags, and call getFeature / getFeatures. All three examples assume composer require supaship/php-sdk is already done.

The SDK supports PHP 7.4+. Laravel examples below use PHP 8.1+ syntax (e.g. readonly constructor promotion). For Symfony, adjust to your version’s PHP requirement.

Evaluations are synchronous (each call waits for the HTTP response unless you wrap them yourself, e.g. queue or async jobs).


Laravel

1. Environment

In .env:

2. Config file (e.g. config/supaship.php)

3. Register the client in app/Providers/AppServiceProvider.php (method register()):

4. Per-request context (e.g. after auth)

In AppServiceProvider::boot() or a middleware:

5. Use in a controller

Optional middleware that only refreshes context is often cleaner than afterResolving when you need Auth::user() on every request.


Symfony

1. Environment

In .env.local (do not commit secrets):

2. Parameters in config/services.yaml (Symfony 6/7 style):

For larger features maps, you can load a dedicated file with imports: or define the array in PHP via a small config class; the important part is passing the same structure into SupashipClient.

3. Service definition in config/services.yaml:

4. Subscriber to attach the current user to the client (example using Symfony security):

Register the subscriber (Symfony auto-wires if App\ is configured; otherwise add explicit service tags for kernel.event_subscriber).

5. Controller


CodeIgniter 4

1. Environment

In .env:

2. Central feature map

Create app/Config/SupashipFeatures.php (or keep the array inside Services if you prefer):

3. Service registration in app/Config/Services.php:

4. Per-request context — e.g. in a filter app/Filters/SupashipContext.php:

Register the filter in app/Config/Filters.php for the routes or groups that need targeting.

5. Controller


Shared tips (all frameworks)

Testing

Unit tests should not call Supaship Edge. Pass an httpHandler under networkConfig (same hook as in Advanced: httpHandler) so SupashipClient never opens a socket.

Supaship\Testing\HttpStub

The package includes a tiny helper so you do not hand-build JSON for every test:

Simulate API or transport failures (client falls back to your configured defaults):

Laravel: testing a route that injects SupashipClient

Your app resolves SupashipClient from the container (e.g. AppServiceProvider registers a singleton). In a feature test you swap that binding for a client wired with HttpStub, then call the route. Laravel will inject your test double instead of the real client.

Assume this route (simplified):

Use the same features fallback map shape as in production (at least the keys you request). Register a client whose httpHandler returns the flag value you want for that test:

Why this works:

Asserting what would be sent to Edge

The handler receives the POST URL and the request body string (JSON). Capture it in a closure when you care about environment, features, or context:

json_decode’s third parameter is the maximum nesting depth; 512 is PHP’s default. On PHP 7.4 you cannot use named arguments, so you pass that default explicitly whenever you need the fourth parameter (JSON_THROW_ON_ERROR). e.g. json_decode($jsonBody, true, 512, JSON_THROW_ON_ERROR).

PHPUnit in your app

Add a dev dependency and point to your tests directory (typical phpunit.xml.dist):

Then run:

The SDK’s own test suite is composer test from a clone of this repository (vendor/bin/phpunit after composer install).

Constants

Supaship\Constants::DEFAULT_FEATURES_URL and DEFAULT_EVENTS_URL match the JavaScript SDK defaults.

Advanced: httpHandler

For production custom HTTP (proxy, corporate CA, tracing), or ad-hoc test doubles, inject a handler (same idea as fetchFn in the JavaScript SDK). For most unit tests, prefer HttpStub in the Testing section.

The handler must return ['statusCode' => int, 'body' => string] where body is the raw JSON response.

Developing & tests (this repository)

This runs PHPUnit on tests/, including stub coverage for Supaship\Testing\HttpStub.

Maintainers: To ship a version from GitHub, use Actions → Publish Supaship PHP SDK (publish.yml): it validates, runs tests, and opens a GitHub Release with auto-generated notes from commits since the last release.

License

MIT — see LICENSE.


All versions of php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-json Version *
ext-openssl 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 supashiphq/php-sdk contains the following files

Loading the files please wait ...