Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['8.1', '8.2', '8.3']
php: ['7.4', '8.0', '8.1', '8.2', '8.3']

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '7.4'
extensions: json, openssl
coverage: none

Expand Down
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ Lightweight, zero-dependency (runtime) client for [Supaship](https://supaship.co

## Requirements

- PHP 8.1+
- PHP 7.4+
- Extensions: `json`, `openssl` (for `https://` to Edge)

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

```bash
Expand Down Expand Up @@ -86,6 +88,8 @@ $client->getFeature('new-ui', ['context' => ['plan' => 'enterprise']]);

`SupaClient` 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 supashiphq/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).

---
Expand Down Expand Up @@ -251,10 +255,17 @@ use Symfony\Component\HttpKernel\KernelEvents;

final class SupashipContextSubscriber implements EventSubscriberInterface
{
public function __construct(
private readonly SupaClient $client,
private readonly Security $security,
) {}
/** @var SupaClient */
private $client;

/** @var Security */
private $security;

public function __construct(SupaClient $client, Security $security)
{
$this->client = $client;
$this->security = $security;
}

public function onKernelRequest(RequestEvent $event): void
{
Expand Down Expand Up @@ -555,6 +566,8 @@ Why this works:

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)`.

```php
$captured = null;

Expand Down
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"type": "library",
"license": "MIT",
"require": {
"php": ">=8.1",
"php": ">=7.4",
"ext-json": "*",
"ext-openssl": "*"
},
"require-dev": {
"phpunit/phpunit": "^10.5"
"phpunit/phpunit": "^9.6.11"
},
"autoload": {
"psr-4": {
Expand All @@ -23,5 +23,10 @@
},
"scripts": {
"test": "phpunit"
},
"config": {
"platform": {
"php": "7.4.33"
}
}
}
Loading
Loading