kongono / framework
A modern, zero-legacy PHP 8.5+ application framework built from the ground up with zero Symfony dependency and integrated Oshie (learn), Chie (build), and Hantei (debug/test) AI companions.
Requires
- php: >=8.5.13
- ext-curl: *
- ext-dom: *
- ext-json: *
- ext-mbstring: *
- ext-pdo: *
- ext-sodium: *
- psr/container: ^2.0
- psr/event-dispatcher: ^1.0
- psr/http-factory: ^1.1
- psr/http-message: ^2.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
- psr/log: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.2
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^13.2
Suggests
- ext-openssl: Required for STARTTLS SMTP email delivery and TLS Redis connections.
- ext-pdo_pgsql: Required for PostgreSQL, pgvector semantic search, and PostgresQueueDriver.
- ext-pdo_sqlite: Optional for lightweight local SQLite databases.
- ext-zlib: Required for HTTP gzip/deflate response compression via CompressionMiddleware.
Provides
None
Conflicts
None
Replaces
- kongono/ai: v1.19.0
- kongono/cli: v1.19.0
- kongono/core: v1.19.0
- kongono/database: v1.19.0
- kongono/http: v1.19.0
- kongono/jobs: v1.19.0
- kongono/mail: v1.19.0
- kongono/security: v1.19.0
- kongono/storage: v1.19.0
- kongono/validation: v1.19.0
- kongono/view: v1.19.0
This package is auto-updated.
Last update: 2026-11-23 05:52:39 UTC
README
Build what comes next.
Kongono is a modern, zero-legacy PHP 8.5+ application framework built from the ground up — zero Symfony packages, zero third-party runtime libraries, zero mutable static state, and zero magic global facades — designed for persistent runtimes (kongo serve, FrankenPHP, RoadRunner, PHP-FPM), hardened against autonomous AI attacks, and featuring three built-in AI companions:
- Oshie (
kongo oshie) — Interactive AI tutor that teaches Kongono grounded in your live app. - Chie (
kongo chie) — Project-aware AI builder & scaffolder that reads yourApplicationGraphand proposes clean PHP 8.5 code. - Hantei (
kongo hantei) — AI debugger, failure analyzer, and PHPUnit 13 test generator.
Why Kongono?
- Pure PHP 8.5.13+ & Zero Bloat: 100%
declare(strict_types=1),final readonlyclasses, attributes, enums, and only the 7 PSR interface packages inrequire— zero Symfony or npm runtime dependencies. - Kongono Live 2.5 & Bridge (
Kongono\Http\Live,Kongono\Http\Bridge):- Live 2.5: Zero-build, strict-CSP reactive hypermedia (
LiveMiddleware,@liveScript,Request::isLive(),Response::fragment()) with keyed DOM morphing, zero-eval()cached-AST signals, optimistic UI, speculative hover/visible prefetch, out-of-band multi-morph (kgn-oob),k-persist+ offline idempotent queue, drag-and-drop (kgn-sortable), View Transitions, and SSE streaming (kgn-stream). - Bridge: First-class React, Vue, and Svelte integration (
BridgeMiddleware,Response::page(),Response::adaptive(),@islandhybrid islands,kongo bridge:init,kongo bridge:types, andkongo ui:add).
- Live 2.5: Zero-build, strict-CSP reactive hypermedia (
- Complete Zero-Vendor Auth & Security (
Kongono\Security):- Session auth (
SessionAuth,SessionAuthMiddleware,#[Authenticated]),Gatepolicies &before()hooks, revocable SHA-256 Personal Access Tokens (Memory/Cache/PDOwith automatickgn_pat_secret scrubbing),PasswordResetBroker,EmailVerifier,LoginThrottler, and theft-detecting split-tokenRememberMeManager. - Native WebAuthn/FIDO2 Passkeys (
PasskeyVerifierES256/Ed25519), single-use HMACMagicLinkAuth, PKCE S256PkceOAuthClient, RFC 6238TotpMFA, Argon2idPasswordHasher, HKDFEncryptorv2 (XChaCha20-Poly1305 AEAD + key rotation), HTML5HtmlSanitizer/@safeHtml,WebhookSigner, and SSRF-pinnedSafeHttpClient.
- Session auth (
- Production Queues, Batches & Durable Workflows (
Kongono\Jobs):PostgresQueueDriver(FOR UPDATE SKIP LOCKED+ fencing tokens), pure-PHP Lua-atomicRedisQueueDriver, andMemoryQueueDriverwith multi-queue priority draining (critical,high,default), dead-letter inspection/replay (kongo queue:failed,queue:retry,queue:flush), atomicuniqueKeydeduplication, composableJobMiddlewareInterface, parallelJobBatch+BatchDispatcher,--daemonworkers, cronScheduler, and durableWorkflow($wf->step(), multi-daysleep(),waitForEvent()/signal()).
- Explicit Data Layer, Migrations & Hybrid Search (
Kongono\Database+Kongono\Ai):- Parameterized
QueryBuilderwith soft deletes (withoutTrashed/onlyTrashed/restore), fail-closedforTenant()+ PostgreSQLRowLevelSecurity, zero-N+1BatchLoader(hasMany/belongsTo) +QueryGuard, and typedFactory::for(). - Full
Schema::table()/Schema::rename()+Blueprint(uuid,json,decimal,foreignId,softDeletes),NonTransactionalMigrationInterface,kongo migrate --pretend, zero-downtimekongo migrate:lint, and production-guardedkongo migrate:fresh. - Native
PostgresFullTextSearch(tsvector/ts_rank_cd, plain-text[[/]]excerpts) fused withPgVectorStore(HNSW/GIN) viaHybridSearch(Reciprocal Rank Fusion) for high-precision RAG retrieval.
- Parameterized
- Streaming Storage & First-Class Testing (
Kongono\Storage+TestClient):- Streaming
putStream/getStreamacrossLocalStorage, pure-PHP AWS SigV4S3Storage(paginatedListObjectsV2, server-sidex-amz-copy-sourcecopy/move, presigned URLs), andMemoryStorage, plus magic-byteUploadedFileStore,SignedLocalUrl,StorageDisks, andResponse::download()/fromStorage(). - Expressive testing without global state:
TestClient(actingAs,withStatefulCookies,postMultipart,followRedirects,withLive,withBridge),TestUpload(fakePng/fakeJpeg/fakePdf/fakeJson), richTestResponseassertions,DatabaseTestHelper::inRollbackTransaction()(with nested SQLSAVEPOINTs), SSRF-enforcingSafeHttpClient::fake(), and pure-DIClockInterface/FrozenClock.
- Streaming
- Built-In
/_opsOperations &/_kongonoTime-Travel Dev Studio:- Capability-gated Live 2.5
/_opsdashboard (OpsDashboardMiddleware— fail-closedGateops.view/ops.manage, live queue depths, 1-click DLQ retry/flush,JobBatchprogress bars,HealthCheck,Metrics, and recent traces). /_kongonoDev Studio with request/SQL inspection, in-process replay (/_kongono/api/replay/{id}), 1-click PHPUnit 13TestExporter, and Oshie/Chie/Hantei browser workbench (auto-disabled in production).
- Capability-gated Live 2.5
- One Backend, Every Platform (
kongo sdk:generate): Generate typed TypeScript, Swift 6, Kotlin, and Dart client SDKs + OpenAPI 3.1.0 +/docsstraight from PHP 8.5 attribute routes and readonly DTOs (including#[ArrayOf],RuleInterface, andValidatableDtoInterface). - Persistent-Runtime Speed (
Async::all()+ AOT Router): Native PHP 8.5 Fiber concurrency (Async::all/race/map/allSettled), parallelSafeHttpClient::requestMany(), zero-reflection dispatch plan caching, PDO/Redis auto-reconnect + statement caching,RedisEventBus,O(1)static + chunked PCRE2 AOTRouter(kongo optimize), and OPcache-compiled.kgn.htmlclosures. - Hardened Against Autonomous AI Attacks + Built-in Eval Suite (
kongo eval):AiThreatShieldMiddleware— recon honeypot traps, hidden form field traps, 404 probe burst auto-banning, and cost-aware compute budget limiting.PromptGuard&UntrustedInput— structural<untrusted_data>isolation, prompt-injection detection, and cryptographic Canary Token fail-closed blocking.kongo eval --redteam— "PHPUnit for AI" asserting structured DTO accuracy, token/latency budgets, and a 12-vector adversarial prompt-injection red-team battery.kongo audit --attack --strict— graph-driven security audit + automated in-process red-team simulations + parser fuzzing (composer fuzz).
- Multi-Provider AI & Native MCP (
kongono/ai):AiClientspeaks OpenAI, Anthropic Claude, Google Gemini, Groq, and local Ollama (all with live streaming) overext-curl, plusstructured()DTO extraction, 5-line RAGKnowledgeBase, governedAgentPrincipal/RequiresApprovalbudgets, and a built-in Model Context Protocol (MCP) Server (kongo mcp/POST /mcp).
Installation & Quick Start
# Create a brand-new Kongono app (includes /_kongono Dev Studio, /docs, /health, /mcp & FrankenPHP Dockerfile) composer create-project kongono/app my-app cd my-app composer dev
Or install kongono/framework directly into an existing project:
composer require kongono/framework
Or run directly from this repository:
# Run the full starter app locally (includes /_kongono Dev Studio, /docs API Explorer, /health, /openapi.json, /metrics, /mcp) php bin/kongo serve --app=examples/starter-app --port=8000 # Security audit, AI red-team evals, migrations, queues & frontend tooling php bin/kongo doctor --app=examples/starter-app php bin/kongo audit --attack --strict --app=examples/starter-app php bin/kongo eval --redteam --app=examples/starter-app php bin/kongo migrate --pretend --app=examples/starter-app php bin/kongo migrate:lint --app=examples/starter-app php bin/kongo queue:failed --app=examples/starter-app php bin/kongo work --daemon --app=examples/starter-app php bin/kongo bridge:types --app=examples/starter-app php bin/kongo sdk:generate --lang=ts --app=examples/starter-app --out=sdk/client.ts php bin/kongo sdk:generate --lang=swift --app=examples/starter-app --out=sdk/Client.swift php bin/kongo sdk:generate --lang=kotlin --app=examples/starter-app --out=sdk/Client.kt php bin/kongo sdk:generate --lang=dart --app=examples/starter-app --out=sdk/client.dart php bin/kongo deploy:init --app=examples/starter-app --domain=app.example.com php bin/kongo optimize --app=examples/starter-app php bin/kongo key:generate php bin/kongo routes --app=examples/starter-app php bin/kongo graph --app=examples/starter-app php bin/kongo openapi --app=examples/starter-app php bin/kongo mcp --app=examples/starter-app php bin/kongo skills:install --target=both --app=examples/starter-app # Use the three built-in AI companions php bin/kongo oshie --lessons php bin/kongo oshie --interactive php bin/kongo oshie "How do I protect an API route with BearerAuthMiddleware?" php bin/kongo chie "Add a /health JSON endpoint" php bin/kongo hantei check
To enable live AI responses for Oshie, Chie, and Hantei, set any one environment variable:
OPENAI_API_KEY(orOPENAI_BASE_URLfor OpenAI-compatible gateways)ANTHROPIC_API_KEYGEMINI_API_KEYGROQ_API_KEY(orGROQ_BASE_URLoverride)OLLAMA_HOST=http://127.0.0.1:11434(free, local, offline!)
Complete 11-Package Architecture
| # | Package | Namespace | Purpose |
|---|---|---|---|
| 1 | packages/core |
Kongono\Core\ |
Persistent Kernel, PSR-11 Container, pure-DI ClockInterface/SystemClock/FrozenClock, Fiber Async, Config, EnvLoader, PSR-3 Logger, MemoryCache/FileCache/pure-PHP RedisClient+RedisCache/CacheFactory, FeatureManager, NotificationDispatcher, Retry/CircuitBreaker, Metrics/Tracer, HealthCheck, I18n\Translator, Diagnostics/SecretScrubber, EventDispatcher, ApplicationGraph |
| 2 | packages/http |
Kongono\Http\ |
PSR-7/15 Request/Response/Cookie/UploadedFile, Kongono Live 2.5 (LiveMiddleware, keyed morphing, CSP-strict signals, kgn-oob, k-persist, kgn-sortable), Kongono Bridge (BridgeMiddleware, Response::page(), Response::adaptive()), Session + PRG flash (old/errors), StaticFilesMiddleware, CompressionMiddleware, #[CacheControl], #[Idempotent], #[Feature], SseEvent + EventBus/RedisEventBus, OpenApiGenerator, /docs, /_kongono Dev Studio, /_ops OpsDashboardMiddleware, TestClient/TestResponse/TestUpload, zero-reflection App, O(1) static + chunked PCRE2 AOT Router |
| 3 | packages/view |
Kongono\View\ |
Compiled .kgn.html OPcache closure templates (warmCache(), autoReload: false), @liveScript, @bridgeScript, @island, @vite(...), @safeHtml, @old(...)/@error(...), layouts, loops, <x-component> slots, @t(...) i18n, @json, automatic context-aware XSS escaping |
| 4 | packages/validation |
Kongono\Validation\ |
PHP 8.5 attribute-driven typed DTO validation (nested DTOs, BackedEnum, #[ArrayOf], RuleInterface, ValidatableDtoInterface, #[Date], #[Ip], #[NotIn], #[RequiredIf], #[Uuid], #[Between], #[Confirmed], #[Email], #[Min]/#[Max], #[In], #[Regex]) |
| 5 | packages/database |
Kongono\Database\ |
Parameterized QueryBuilder (soft deletes, fail-closed forTenant() + PostgreSQL RowLevelSecurity, JOIN, whereGroup(), upsert(), GROUP BY, HAVING, RETURNING, paginate(), getAs(), insertMany()), ConnectionManager & ReadWriteConnection (named connections, read replicas, sticky-after-write), BatchLoader (hasMany/belongsTo), QueryGuard, Factory, Schema/Blueprint (table/rename/softDeletes/foreignId), PdoConnection (auto-reconnect, stmt cache, nested SAVEPOINT transactions), DatabaseTestHelper, Migrator (migrate --pretend, rollback, fresh, lint), PostgresFullTextSearch/MemorySearchEngine, Repository, SeederInterface |
| 6 | packages/security |
Kongono\Security\ |
SessionAuth + #[Authenticated], revocable SHA-256 PersonalAccessToken (Memory/Cache/Pdo PersonalAccessTokenStore), PasswordResetBroker, EmailVerifier, LoginThrottler, RememberMeManager, WebAuthn PasskeyVerifier, MagicLinkAuth, PkceOAuthClient, AiThreatShieldMiddleware, Principal, Gate (policies + before()), #[Can], HtmlSanitizer, RFC 6238 Totp, WebhookSigner/WebhookDispatcher/#[VerifyWebhook], Argon2id PasswordHasher, HKDF Encryptor v2, TokenSigner/SignedUrl, CSRF/CORS/Bearer/RateLimit/SecurityHeaders middleware, SSRF-pinned SafeHttpClient + SafeHttpClient::fake() |
| 7 | packages/storage |
Kongono\Storage\ |
Streaming (putStream/getStream), copy/move, contained atomic LocalStorage, pure PHP 8.5 AWS SigV4 S3Storage (S3/R2/MinIO, paginated ListObjectsV2, native server-side copy, presigned URLs), MemoryStorage, StorageDisks, StorageFactory, magic-byte UploadedFileStore, SignedLocalUrl |
| 8 | packages/jobs |
Kongono\Jobs\ |
Background Queue, persistent/daemon Worker (multi-queue priority draining, JobMiddlewareInterface), dead-letter listFailed/retryFailed/flushFailed, atomic uniqueKey dedup, parallel JobBatch + BatchDispatcher, durable Workflow, PostgresQueueDriver (FOR UPDATE SKIP LOCKED + fencing tokens), Lua-atomic RedisQueueDriver, MemoryQueueDriver, cluster-safe cron Scheduler (withoutOverlapping(), onOneServer()) |
| 9 | packages/mail |
Kongono\Mail\ |
Zero-dependency transactional email (SmtpTransport STARTTLS, ResendTransport, LogTransport, MemoryTransport, MailNotificationChannel, .kgn.html email views) |
| 10 | packages/ai |
Kongono\Ai\ |
Multi-provider AiClient (OpenAI, Anthropic, Gemini, Ollama) with live streaming, PromptGuard + UntrustedInput (canary tokens + injection detection), EvalRunner, vector embeddings (MemoryVectorStore + PgVectorStore HNSW/GIN), HybridSearch (Reciprocal Rank Fusion), 5-line RAG KnowledgeBase, structured() DTO extraction, governed AgentPrincipal/RequiresApproval/AgentRunner, and native McpServer (JSON-RPC 2.0) |
| 11 | packages/cli |
Kongono\Cli\ |
Unified kongo CLI (`new [--starter=minimal |
(Historical Phase 0–23 architecture archives remain preserved on the main and archive/phase-23c-wip branches.)
Quality Checks
composer dump-autoload composer cs # PHP-CS-Fixer composer analyse # PHPStan level 9 + strict rules composer test # PHPUnit 13 composer fuzz # Adversarial parser & security fuzzer composer test:integration # Live PostgreSQL 16 (pgvector) + Redis 7 integration suite composer quality # Run cs + analyse + test
Documentation
- Official Documentation Site (GitHub Pages) ·
llms.txt·llms-full.txt - Community Discussions
- Getting Started
- Architecture Overview
- Built-In AI Companions & MCP Server
- Production Deployment & Scaling Guide
- Persistent-Worker Benchmark (
php examples/benchmark.php) - Changelog · Contributing · Security Policy
License
MIT — see LICENSE.