PHPackages                             purple-php/sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. purple-php/sdk

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

purple-php/sdk
==============

Enterprise AI modernization SDK for PHP applications.

v0.1.0(1mo ago)02↓90%1MITPHPPHP ^8.2CI passing

Since Jun 5Pushed 1mo agoCompare

[ Source](https://github.com/LynnColeArt/purple-php)[ Packagist](https://packagist.org/packages/purple-php/sdk)[ RSS](/packages/purple-php-sdk/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (1)

Purple PHP
==========

[](#purple-php)

[![Purple PHP hero graphic](hero.png)](hero.png)

Purple PHP is an enterprise AI modernization SDK for existing PHP applications.

It is designed for teams with significant sunk cost in PHP-based CMS, ecommerce, admin, support, catalog, and workflow systems. The goal is to add secure, auditable AI behavior without rewriting the application estate.

Current Shape
-------------

[](#current-shape)

Purple PHP is Composer-first. Native runtime, sidecar, and PHP extension support may become important deployment modes later, but the developer-facing center of gravity is PHP.

The current SDK includes:

- Smart functions: typed, auditable AI calls for narrow repeatable tasks.
- Chat sessions: stateful assistant flows with role-aware history and chunkable responses.
- Tool contracts: named, schema-validated tools with input/output schemas and side-effect levels.
- Looping agents: goal-driven runners that can call tools under limits, hooks, policy, audit, retries, replay logs, and approvals.
- Runtime hooks: extension points around provider requests, tool calls, and agent lifecycle events.
- CLI support: a `purple` command for demos, diagnostics, provider checks, sidecar resume prototyping, and audit inspection.
- Enterprise workflow ports: CMS-agnostic content, catalog, order, support, approval, and audit adapters.
- Enterprise hardening: tenant/data-residency policy metadata, advanced policy rules, PII redaction, contextual/Vault/cloud secret lookup, Azure and sidecar providers, optional Bedrock provider package, and SIEM/observability export.
- Optional runtime readiness: native bridge contracts, sidecar envelopes, sandboxed tool execution, durable run storage, runtime metrics, and on-prem deployment metadata.

The first milestone was smart functions. Phases 2, 3, 4, and 5 are now represented in the Composer-first SDK as chat, CLI, tools, looping agents, approvals, runtime hooks, retry behavior, run state, replayable tool logs, enterprise policy, secret adapters, cloud provider adapters, sidecar brokerage, observability export, and optional native/runtime readiness contracts.

Phase 5.1 makes that runtime work executable as Composer-safe contracts: native acceptance, sidecar resume, and package-split decisions stay testable through PHP fixtures, fake providers, injectable transports, and ignored local runtime paths. The Bedrock package split applies that same baseline to enterprise providers: a normal core Composer install still does not require Bedrock, a native extension, a sidecar process, cloud SDK dependencies, or live network services.

Phase 5.3 made the Bedrock provider package release-ready. The `0.1.0` GitHub release line now publishes the root SDK from `LynnColeArt/purple-php` and the optional Bedrock provider from `LynnColeArt/purple-php-provider-bedrock` while preserving the Composer-first baseline.

Phase 5.4 adds a local sidecar runtime service prototype for durable resume. It accepts the same `purple.sidecar.v1` resume envelope used by the PHP contract tests, reads a local durable run store, and returns deterministic accepted/rejected response envelopes without requiring a sidecar daemon, socket listener, native extension, cloud SDK, or live network service.

Phase 5.5 adds a native extension compatibility prototype. `NativeRuntimeCompatibility` runs the native acceptance ping against any `NativeRuntime`, `bin/purple native check fixture` proves the path with Composer-safe PHP, and `bin/purple native check extension [extension-name]` lets platform teams check an installed extension deliberately.

Quick Start
-----------

[](#quick-start)

```
composer install
php examples/smart-functions/sdk-quickstart.php
php examples/smart-functions/catalog-summary.php
php examples/chat/fake-chat.php
php examples/agents/catalog-agent.php
php examples/runtime/durable-sidecar-handoff.php
php examples/runtime/durable-sidecar-resume.php
php bin/purple sidecar resume var/runtime/runs run-resume-example
php bin/purple native check fixture
php bin/purple demo smart-function
php bin/purple demo chat
php bin/purple demo agent
```

The `Sdk` entry point bundles a provider, model, policy, audit log, and schema validator for common setup:

```
use Purple\Sdk;
use Purple\Testing\FakeProvider;

$sdk = new Sdk(
    provider: FakeProvider::replying('{"summary":"Ready for catalog review."}'),
    providerName: 'fake',
    model: 'fake-model',
);

$summary = $sdk->smartFunction(
    name: 'catalog.summary',
    prompt: 'Summarize {{ title }} as JSON.',
    outputSchema: '{"type":"object","required":["summary"],"properties":{"summary":{"type":"string"}}}',
)->run(['title' => 'Merino travel cardigan']);
```

For named provider setup, use `ProviderProfile` factories:

```
use Purple\ProviderProfile;
use Purple\Sdk;

$sdk = Sdk::openAI(
    profile: ProviderProfile::openAI(
        model: 'gpt-4.1-mini',
        secretName: 'OPENAI_API_KEY',
    ),
);
```

When installed as a Composer dependency, the CLI is exposed as:

```
vendor/bin/purple diagnostics
vendor/bin/purple audit inspect var/audit/catalog.jsonl
vendor/bin/purple demo chat
vendor/bin/purple demo agent
vendor/bin/purple provider check openai
vendor/bin/purple sidecar resume var/runtime/runs run-resume-example
vendor/bin/purple native check fixture
```

Provider Security
-----------------

[](#provider-security)

Provider credentials are resolved through `SecretResolver` implementations instead of being passed around as normal strings in application code. `EnvironmentSecretResolver` reads named environment variables, and `SecretValue` redacts itself when stringified.

The OpenAI profile defaults to `OPENAI_API_KEY`, and `.env.example` documents the expected local setup without including secret values.

```
cp .env.example .env
vendor/bin/purple provider check openai
```

Tests and local examples can use `FakeProvider` to avoid external provider calls.

Optional Bedrock Provider
-------------------------

[](#optional-bedrock-provider)

AWS Bedrock support lives in the optional package `purple-php/provider-bedrock` under [packages/provider-bedrock](packages/provider-bedrock/) in this monorepo and as the standalone public release repository `LynnColeArt/purple-php-provider-bedrock`. It is not required by the root `purple-php/sdk` package.

Local monorepo validation uses the package working directory:

```
composer install --working-dir=packages/provider-bedrock
composer check --working-dir=packages/provider-bedrock
```

Applications that install the Bedrock package can use the package-local factory instead of the former root `Sdk::bedrock()` convenience method:

```
use Purple\Provider\Bedrock\BedrockSdk;
use Purple\ProviderProfile;

$sdk = BedrockSdk::create(
    profile: ProviderProfile::bedrock(model: 'anthropic.model'),
    region: 'us-east-1',
);
```

The package currently uses injectable transports and fixtures for validation. Real AWS signing, credential discovery, AWS SDK integrations, and live Bedrock calls remain future opt-in work.

Enterprise Principles
---------------------

[](#enterprise-principles)

Purple PHP treats existing PHP estates as valuable terrain.

The SDK should be:

- Composer-first
- provider-neutral
- secure by default
- auditable by default
- policy-driven
- CMS-agnostic
- ecommerce-aware
- optional-native, not native-required

Runtime continuation is executable only where teams opt into it. Composer mode remains the default baseline for local development, tests, examples, and package adoption.

Policy is enforcement. Hooks are extension points.

Validation
----------

[](#validation)

```
composer check
```

The check script runs PHPUnit, PHPStan, and php-cs-fixer in dry-run mode.

Acknowledgements
----------------

[](#acknowledgements)

Special thanks to Patrick Haley at Apex Systems, whose memorable recruiting style reminded me that finishing this project would be more effective than allowing him to waste my time.

Planning Artifacts
------------------

[](#planning-artifacts)

The current project outline lives in [outline.md](outline.md).

Spec Kitty mission packages:

- Enterprise SDK foundation: [kitty-specs/001-purple-php-enterprise-ai-sdk](kitty-specs/001-purple-php-enterprise-ai-sdk/spec.md)
- Runtime continuation Phase 5.1: [kitty-specs/runtime-continuation-mega-mission-01KTA3AD](kitty-specs/runtime-continuation-mega-mission-01KTA3AD/spec.md)
- Bedrock provider package split: [kitty-specs/bedrock-provider-package-split-01KTAHKT](kitty-specs/bedrock-provider-package-split-01KTAHKT/spec.md)
- Bedrock provider release readiness: [kitty-specs/provider-bedrock-release-readiness-01ktan01-01KTAMNF](kitty-specs/provider-bedrock-release-readiness-01ktan01-01KTAMNF/spec.md)
- Sidecar runtime service prototype: [kitty-specs/sidecar-runtime-service-prototype-01KTAQ1M](kitty-specs/sidecar-runtime-service-prototype-01KTAQ1M/spec.md)
- Native extension compatibility prototype: [kitty-specs/native-extension-compatibility-prototype-01KTAS1B](kitty-specs/native-extension-compatibility-prototype-01KTAS1B/spec.md)

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance90

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

50d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5f4b938e8de120aff57449b61308f89d6662c4a94e74f79910fd23756afca881?d=identicon)[LynnColeArt](/maintainers/LynnColeArt)

---

Top Contributors

[![LynnColeArt](https://avatars.githubusercontent.com/u/131792457?v=4)](https://github.com/LynnColeArt "LynnColeArt (212 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/purple-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/purple-php-sdk/health.svg)](https://phpackages.com/packages/purple-php-sdk)
```

###  Alternatives

[dmitryd/typo3-realurl

Speaking URLs for TYPO3

112911.2k9](/packages/dmitryd-typo3-realurl)[badcow/phrase-generator

Generate an English adjective-noun pair as a phrase (e.g. SubmissiveMonkey).

146.4k](/packages/badcow-phrase-generator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
