PHPackages                             token27/nexus-ai-prompts - 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. [Templating &amp; Views](/categories/templating)
4. /
5. token27/nexus-ai-prompts

ActiveLibrary[Templating &amp; Views](/categories/templating)

token27/nexus-ai-prompts
========================

Framework-agnostic prompt registry with Mustache templating, versioning, multi-language fallback, and multi-directory support

v1.0.0(2w ago)014↓100%MITPHPPHP ^8.3CI passing

Since May 20Pushed 2w agoCompare

[ Source](https://github.com/token27/nexus-ai-prompts)[ Packagist](https://packagist.org/packages/token27/nexus-ai-prompts)[ Docs](https://github.com/token27/nexus-ai-prompts)[ RSS](/packages/token27-nexus-ai-prompts/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

nexus-ai-prompts
================

[](#nexus-ai-prompts)

[![CI](https://github.com/token27/nexus-ai-prompts/actions/workflows/ci.yml/badge.svg)](https://github.com/token27/nexus-ai-prompts/actions)[![PHPStan Level 8](https://camo.githubusercontent.com/412205ac46adf8d1c9329cfcacca7da2697c664b7f1ffd18076a4a17c1e9de6d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230382d316636666562)](https://phpstan.org/)[![Latest Version](https://camo.githubusercontent.com/f9241da51ff431dd98d9c919b4fef036dcef9b9a4117caac405502cd802ab2a7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f6b656e32372f6e657875732d61692d70726f6d7074732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/token27/nexus-ai-prompts)[![PHP 8.3+](https://camo.githubusercontent.com/38027453aeb7eb818641c9de8f82b7624c3558d92634f1946edc715c3ddf8956/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://php.net)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](LICENSE)[![Tests](https://camo.githubusercontent.com/ea239e82d74362a9b6b85ec2d42056dd5359a94b7ecfa3fa4b0c5d43305aa6b8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54657374732d31333225323070617373696e672d627269676874677265656e)](#testing)

A **universal, framework-agnostic** PHP 8.3+ prompt engine. Manage complex, multimodal, and weighted prompts as versioned resources. Render to any AI provider (OpenAI, Anthropic, Gemini, Stability AI, etc.) with a single fluent API.

Why nexus-ai-prompts?
---------------------

[](#why-nexus-ai-prompts)

AI payloads are fragmented. OpenAI wants `messages[]`, Anthropic wants `system` + `messages[]`, Gemini wants `parts[]`, and Image/Video models want simple strings.

**nexus-ai-prompts** solves this by:

- **Block-based architecture**: Prompts are collections of flexible blocks, not just chat roles.
- **Provider-agnostic core**: Render once, format for any API (8 built-in formatters).
- **First-class versioning**: Ship `v1.0.0` today, test `v2.0.0` tomorrow, rollback instantly.
- **Multi-language cascade**: Automatic fallback from `es_AR` → `es` → `en`.
- **Fluent API**: Entry points for every workflow — from static one-liners to complex builders.

Features
--------

[](#features)

- **Universal Prompt Storage**: JSON-based prompts with `meta`, `blocks`, and `variables`.
- **8 Output Formatters**: OpenAI, Anthropic, Gemini, PlainString, Completion, Stability AI, Ollama, Embedding.
- **Mustache Templating**: Full logic support (`{{variable}}`, `{{#section}}`) with strict variable validation.
- **`latest` version resolution**: Always resolve to the highest semantic version automatically.
- **Discovery**: `autoloadFrom()` registers whole libraries; `PromptFinder::scan()` discovers prompts on disk.
- **Zero Config Raw Prompts**: Render dynamic templates on-the-fly via `PromptEngine::raw()`.
- **Type Safety**: PHPStan Level 8, production-grade architecture.

Installation
------------

[](#installation)

```
composer require token27/nexus-ai-prompts
```

**Requires:** PHP 8.3+ · `mustache/mustache ^2.14` · `league/flysystem ^3.0`

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

[](#quick-start)

### 1. Static One-Liners (No Registry)

[](#1-static-one-liners-no-registry)

```
use Token27\NexusAI\Prompts\PromptEngine;

// Image/Video Prompt
$str = PromptEngine::raw("A {{animal}} in space", ['animal' => 'cat'])->asPlainString();

// Chat Prompt
$messages = PromptEngine::chat([
    ['role' => 'system', 'content' => 'You are {{persona}}'],
    ['role' => 'user', 'content' => 'Hello!'],
], ['persona' => 'helpful'])->asOpenAI();
```

### 2. Fluent Builder

[](#2-fluent-builder)

```
$payload = PromptEngine::build()
    ->system('You are {{persona}}')
    ->user('Explain {{topic}}')
    ->variables(['persona' => 'teacher', 'topic' => 'Quantum Physics'])
    ->render()
    ->asAnthropic(); // returns ['system' => '...', 'messages' => [...]]
```

### 3. Versioned Registry (JSON Files)

[](#3-versioned-registry-json-files)

**File: `resources/prompts/article/research/v1.0.0/en.json`**

```
{
    "meta": { "version": "1.0.0", "prompt_type": "research", "language": "en" },
    "blocks": [
        { "role": "system", "content": "Expert researcher in {{field}}." },
        { "role": "user",   "content": "Topic: {{topic}}" }
    ],
    "variables": {
        "field": { "type": "string", "required": false, "default": "AI" },
        "topic": { "type": "string", "required": true }
    }
}
```

**Usage:**

```
$registry->autoloadFrom(__DIR__ . '/..');

$payload = $registry->resolve('article/research')
    ->render(['topic' => 'PHP 8.4'])
    ->asGemini(); // returns ['contents' => [['role' => 'user', 'parts' => [...]]]]
```

Documentation
-------------

[](#documentation)

- [Prompt Format](docs/prompt-format.md) — The new `blocks` schema
- [Fluent API (Engine &amp; Builder)](docs/fluent-api.md) — Create prompts on-the-fly
- [Output Formatters](docs/output-formats.md) — OpenAI, Anthropic, Gemini, etc.
- [Registry &amp; Resolution](docs/registry.md) — Loading versioned prompts
- [Language Fallback](docs/language-fallback.md) — How the cascade works
- [Multi-Source](docs/multi-source.md) — handling name collisions
- [PromptFinder](docs/prompt-finder.md) — zero-config discovery
- [Advanced Integration](docs/advanced-integration.md) — Ecosystem usage and Custom formatters
- [Architecture](docs/architecture.md) — How the blocks system works
- [Internal Logic &amp; Diagrams](docs/internals.md) — Sequence diagrams and deep-dives
- [Testing](docs/testing.md) — How to test your prompts
- [Troubleshooting](docs/troubleshooting.md) — Exceptions, errors and common solutions

License
-------

[](#license)

MIT. See [LICENSE](LICENSE).

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance96

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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

20d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/78189912?v=4)[Token27](/maintainers/token27)[@token27](https://github.com/token27)

---

Top Contributors

[![token27](https://avatars.githubusercontent.com/u/78189912?v=4)](https://github.com/token27 "token27 (1 commits)")

---

Tags

phpi18ntemplatingversioningmustacheregistryprompts

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/token27-nexus-ai-prompts/health.svg)

```
[![Health](https://phpackages.com/badges/token27-nexus-ai-prompts/health.svg)](https://phpackages.com/packages/token27-nexus-ai-prompts)
```

###  Alternatives

[wrklst/docxmustache

docx template manipulation class, based on mustache templating language

578.3k](/packages/wrklst-docxmustache)[zombor/kostache

Logic-less View/Mustache Module for the Kohana Framework

1382.1k2](/packages/zombor-kostache)[bobthecow/mustache-bundle

Symfony Mustache.php Bundle

1887.5k](/packages/bobthecow-mustache-bundle)[mustache/silex-provider

A Mustache service provider for Silex.

1563.1k1](/packages/mustache-silex-provider)[brightmachine/laratash

A Laravel 5+ wrapper for mustache.php, a PHP implementation of http://mustache.github.io/

1214.8k](/packages/brightmachine-laratash)[dearon/slim-mustache

Mustache View Parser package for the Slim Framework

144.9k2](/packages/dearon-slim-mustache)

PHPackages © 2026

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