Smallwork
A small footprint full-stack AI framework for PHP
Build AI-powered web applications with a unified multi-provider AI gateway, server-rendered templates, JSON APIs, vector search, and enterprise features — without the overhead of a large framework.
composer require smallwork/smallwork
cp .env.example .env
php smallwork serveMulti-Provider AI Gateway
Unified interface across OpenAI, Anthropic, and Grok. Switch providers per request with zero code changes.
Templates + HTMX
Server-rendered Blade-like templates with built-in HTMX helpers. Interactive UIs without writing JavaScript.
Vector Search & RAG
Embeddings, semantic search, and retrieval-augmented generation with Qdrant and pgvector support.
JWT Auth & RBAC
JWT tokens, API key management, role-based access control with permission middleware out of the box.
Database & Query Builder
Fluent query builder with SQLite, MySQL, and PostgreSQL. Migrations, transactions, and Redis support.
Built-in Middleware
CORS, rate limiting, authentication, and AI-powered middleware for content moderation, intent classification, and summarization.
Concise by design
Set up an AI-powered chat endpoint with streaming in a few lines:
$gateway = new Gateway(defaultProvider: 'openai');
$gateway->register('openai', new OpenAIProvider(
baseUrl: 'https://api.openai.com/v1',
apiKey: env('OPENAI_API_KEY'),
));
$router->post('/api/chat', function (Request $request) use ($gateway) {
$chat = new Chat(gateway: $gateway, systemPrompt: 'You are a helpful assistant.');
$response = $chat->send($request->json('message'));
return Response::json($response);
});