Skip to content

Commit 6acbde4

Browse files
committed
docs: add PHP SDK across all guides, fix Python mode parameter, update nav with Packagist link
1 parent 6ed9eeb commit 6acbde4

7 files changed

Lines changed: 229 additions & 75 deletions

File tree

docs/.vitepress/config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ export default defineConfig({
2121
{ text: 'Features', link: '/features/insights' },
2222
{ text: 'API Reference', link: '/guide/configuration' },
2323
{
24-
text: 'v2.0.0',
24+
text: 'SDKs',
2525
items: [
2626
{ text: 'Changelog (Node.js)', link: 'https://github.com/APIForge-Organisation/sdk-nodejs/blob/main/CHANGELOG.md' },
2727
{ text: 'Changelog (Python)', link: 'https://github.com/APIForge-Organisation/sdk-python/blob/main/CHANGELOG.md' },
28+
{ text: 'Changelog (PHP)', link: 'https://github.com/APIForge-Organisation/sdk-composer/blob/main/CHANGELOG.md' },
2829
{ text: 'npm — apiforgejs', link: 'https://www.npmjs.com/package/apiforgejs' },
2930
{ text: 'PyPI — apiforgepy', link: 'https://pypi.org/project/apiforgepy/' },
31+
{ text: 'Packagist — apiforgephp', link: 'https://packagist.org/packages/apiforge/apiforgephp' },
3032
],
3133
},
3234
],

docs/features/insights.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ Identifies endpoints that have received no traffic for an extended period — sa
4646

4747
Compares performance metrics before and after a deployment, when a `release` tag is configured.
4848

49-
> **PERF***"`POST /orders` P99 latency increased by 40% after deploying v1.3.0 (14h32 yesterday). Before: 230ms — After: 322ms."*
49+
> **PERF***"`POST /orders` P99 latency increased by 40% after deploying v1.3.0. Before: 230ms — After: 322ms."*
5050
51-
> **OK***"Deploy v1.4.0 (3 hours ago) introduced no detectable regression. Latency stable, error rate unchanged."*
51+
> **OK***"Deploy v1.4.0 improved `GET /products` by 12%. Before: 85ms — After: 75ms."*
5252
5353
**Triggers when:** A `release` value is set in the config and at least 30 minutes of post-deploy data is available.
5454

@@ -62,10 +62,12 @@ Identifies routes declared in your router that have never received a single requ
6262

6363
> *"`POST /admin/export` is declared in the router but has never received any traffic."*
6464
65-
**Triggers when:** A route appears in the Express / FastAPI router but has zero entries in the metrics database.
65+
**Triggers when:** A route appears in the router registry but has zero entries in the metrics database.
6666

67-
::: tip Node.js only
68-
UNTRACKED insights require that the SDK can inspect the Express router at startup. They are not generated for routes registered after the first request.
67+
::: tip Available on all SDKs
68+
- **Node.js** — scans the Express router automatically on the first request
69+
- **Python** — scans the Starlette/FastAPI router automatically on the first request
70+
- **PHP / Laravel** — syncs the Laravel route registry via the ServiceProvider on boot
6971
:::
7072

7173
---
@@ -89,7 +91,6 @@ Set the `release` option to activate `PERF` and `OK` insights:
8991

9092
```js [Node.js]
9193
app.use(apiforge({
92-
mode: 'local',
9394
release: process.env.npm_package_version,
9495
}))
9596
```
@@ -98,11 +99,14 @@ app.use(apiforge({
9899
import os
99100
app.add_middleware(
100101
ApiForgeMiddleware,
101-
mode="local",
102102
release=os.environ.get("RELEASE"),
103103
)
104104
```
105105

106+
```bash [PHP / Laravel (.env)]
107+
APIFORGE_RELEASE=v1.4.0
108+
```
109+
106110
:::
107111

108112
Each time the value changes (i.e. on a new deploy), APIForge creates a comparison baseline automatically.

docs/features/release-tracking.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Pass the current version as the `release` option:
1010

1111
```js [Node.js]
1212
app.use(apiforge({
13-
mode: 'local',
1413
release: process.env.npm_package_version,
1514
}))
1615
```
@@ -19,23 +18,32 @@ app.use(apiforge({
1918
import os
2019
app.add_middleware(
2120
ApiForgeMiddleware,
22-
mode="local",
2321
release=os.environ.get("RELEASE"),
2422
)
2523
```
2624

25+
```bash [PHP / Laravel (.env)]
26+
APIFORGE_RELEASE=v1.4.0
27+
# or use APP_VERSION which is read by default
28+
```
29+
2730
:::
2831

2932
Or hardcode it during the deploy process:
3033

3134
::: code-group
3235

3336
```js [Node.js]
34-
app.use(apiforge({ mode: 'local', release: 'v1.4.0' }))
37+
app.use(apiforge({ release: 'v1.4.0' }))
3538
```
3639

3740
```python [Python]
38-
app.add_middleware(ApiForgeMiddleware, mode="local", release="v1.4.0")
41+
app.add_middleware(ApiForgeMiddleware, release="v1.4.0")
42+
```
43+
44+
```php [PHP / Laravel]
45+
// config/apiforge.php
46+
'release' => env('APIFORGE_RELEASE', config('app.version')),
3947
```
4048

4149
:::
@@ -54,9 +62,7 @@ Most CI/CD systems expose the version or git tag as an environment variable. Inj
5462

5563
| Metric | Compared |
5664
|---|---|
57-
| P50 latency | Before vs after |
5865
| P90 latency | Before vs after |
59-
| P99 latency | Before vs after |
6066
| Error rate (4xx + 5xx) | Before vs after |
6167

6268
## Example insights generated
@@ -65,7 +71,7 @@ Most CI/CD systems expose the version or git tag as an environment variable. Inj
6571
✅ OK v1.4.0 (deployed 3h ago) — No regression detected.
6672
Latency stable across 12 endpoints. Error rate unchanged.
6773
68-
⚠️ PERF POST /checkout — P99 +38% after v1.4.0
74+
⚠️ PERF POST /checkout — P90 +38% after v1.4.0
6975
Before: 210ms · After: 290ms
7076
Consider reviewing changes to the checkout handler.
7177

docs/guide/cloud-mode.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Cloud mode sends your metrics to the APIForge SaaS instead of storing them local
88
|---|---|---|
99
| Setup | Zero config | Requires an API key |
1010
| Data storage | SQLite on your server | APIForge SaaS |
11-
| Dashboard | Embedded (port 4242) | Cloud dashboard |
11+
| Dashboard | Embedded (port 4242 / `/_apiforge`) | Cloud dashboard |
1212
| Multi-service | One DB per machine | Unified across all services |
1313
| Internet required | No | Yes |
1414

@@ -55,6 +55,18 @@ app.add_middleware(
5555
)
5656
```
5757

58+
```php [PHP / Laravel]
59+
// .env
60+
// APIFORGE_CLOUD_URL=https://api.apiforge.fr
61+
// APIFORGE_API_KEY=af_...
62+
// APIFORGE_SERVICE=my-api
63+
64+
// bootstrap/app.php — no code change vs local mode
65+
->withMiddleware(function (Middleware $middleware) {
66+
$middleware->append(\ApiForge\Laravel\ApiForgeMiddleware::class);
67+
})
68+
```
69+
5870
:::
5971

6072
### 3. Set environment variables
@@ -66,10 +78,14 @@ APIFORGE_API_KEY=af_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
6678

6779
## How it works
6880

69-
1. The SDK intercepts each request and records route, method, status code, and latency in memory.
70-
2. Every `flushInterval` milliseconds (default: 60s), the buffer is aggregated into per-route statistics and sent to `POST /ingest` on the SaaS API.
81+
1. The SDK intercepts each request and records route, method, status code, and latency.
82+
2. Every `flushInterval` (default: 60 s), the buffer is aggregated into per-route statistics and sent to `POST /ingest` on the SaaS API.
7183
3. The SaaS stores the metrics in TimescaleDB and makes them available through the cloud dashboard.
7284

85+
::: info PHP buffering
86+
PHP does not have a long-running process, so the SDK uses a file-based buffer (`/tmp/apiforgephp_*.jsonl`). Events accumulate per request and are flushed on the first request after `APIFORGE_FLUSH_INTERVAL` seconds.
87+
:::
88+
7389
## Circuit breaker
7490

7591
If the SaaS API is unreachable, the SDK automatically backs off:
@@ -78,11 +94,13 @@ If the SaaS API is unreachable, the SDK automatically backs off:
7894
- During the pause, flush calls are silently skipped — your application is never blocked.
7995
- After the pause, the SDK resumes sending normally.
8096

81-
A warning is printed to stdout when the circuit opens:
97+
A warning is logged when the circuit opens:
8298

8399
```
84-
[apiforgejs] Cloud flush failures — pausing for 60s. Error: ...
85-
[apiforgepy] Cloud flush failures — pausing for 60s. Error: ...
100+
[apiforgejs] Cloud flush failures — pausing for 60s. Error: ...
101+
[apiforgepy] Cloud flush failures — pausing for 60s. Error: ...
102+
[apiforgephp] Cloud flush error: HTTP 503 — ...
103+
[apiforgephp] Circuit open — pausing for 60s.
86104
```
87105

88106
## Rotating an API key

0 commit comments

Comments
 (0)