tina4stack / tina4php
Tina4 for PHP — 54 built-in features, zero dependencies
Requires
- php: >=8.2
- ext-json: *
- ext-openssl: *
Requires (Dev)
- phpunit/phpunit: ^10 || ^11
- v3.x-dev
- v3.10.54
- v3.10.50
- v3.10.49
- v3.10.48
- v3.10.47
- v3.10.46
- v3.10.45
- v3.10.44
- v3.10.42
- v3.10.41
- v3.10.40
- v3.10.39
- v3.10.38
- v3.10.37
- v3.10.36
- v3.10.35
- v3.10.34
- v3.10.33
- v3.10.32
- v3.10.31
- v3.10.30
- v3.10.29
- v3.10.28
- v3.10.27
- v3.10.26
- 3.10.24
- 3.10.23
- 3.10.22
- 3.10.21
- 3.10.20
- 3.10.18
- 3.10.17
- 3.10.15
- 3.10.14
- 3.10.13
- 3.10.12
- 3.10.11
- 3.10.10
- 3.10.6
- 3.10.5
- 3.10.4
- 3.10.3
- 3.10.2
- 3.10.1
- v3.10.0
- v3.9.4
- v3.9.3
- v3.9.2
- v3.9.1
- v3.9.0
- v3.8.7
- v3.8.3
- v3.8.2
- v3.8.1
- v3.8.0
- v3.7.2
- v3.7.1
- v3.7.0
- v3.6.0
- v3.5.0
- v3.4.0
- v3.3.0
- v3.2.2
- v3.2.1
- v3.2.0
- v3.1.2
- 3.1.0
- 3.0.0-rc.1
- v2.x-dev
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.99
- v2.0.98
- v2.0.97
- v2.0.96
- v2.0.95
- v2.0.94
- v2.0.93
- v2.0.92
- v2.0.91
- v2.0.90
- v2.0.89
- v2.0.88
- v2.0.87
- v2.0.86
- v2.0.85
- v2.0.84
- v2.0.83
- v2.0.82
- v2.0.81
- v2.0.80
- v2.0.79
- v2.0.78
- v2.0.77
- v2.0.76
- v2.0.75
- v2.0.74
- v2.0.73
- v2.0.72
- v2.0.71
- v2.0.70
- v2.0.69
- v2.0.68
- v2.0.67
- v2.0.64
- v2.0.63
- v2.0.62
- v2.0.61
- v2.0.60
- v2.0.59
- v2.0.58
- v2.0.57
- v2.0.56
- v2.0.55
- v2.0.54
- v2.0.53
- v2.0.52
- v2.0.51
- v2.0.50
- v2.0.49
- v2.0.48
- v2.0.47
- v2.0.46
- v2.0.45
- v2.0.44
- v2.0.43
- v2.0.42
- v2.0.41
- v2.0.40
- v2.0.39
- v2.0.38
- v2.0.37
- v2.0.36
- v2.0.35
- v2.0.34
- v2.0.33
- v2.0.32
- v2.0.31
- v2.0.30
- v2.0.29
- v2.0.28
- v2.0.27
- v2.0.26
- v2.0.25
- v2.0.24
- v2.0.23
- v2.0.22
- v2.0.21
- v2.0.20
- v2.0.19
- v2.0.18
- v2.0.17
- v2.0.16
- v2.0.15
- v2.0.14
- v2.0.13
- v2.0.12
- v2.0.11
- v2.0.10
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v0.1.123
- v0.1.122
- v0.1.121
- v0.1.120
- v0.1.119
- v0.1.118
- v0.1.117
- v0.1.116
- v0.1.115
- v0.1.114
- v0.1.113
- v0.1.112
- v0.1.111
- v0.1.110
- v0.1.109
- v0.1.108
- v0.1.107
- v0.1.106
- v0.1.105
- v0.1.104
- v0.1.103
- v0.1.102
- v0.1.101
- v0.1.100
- v0.1.99
- v0.1.98
- v0.1.97
- v0.1.96
- v0.1.95
- v0.1.94
- v0.1.93
- v0.1.92
- v0.1.91
- v0.1.90
- v0.1.89
- v0.1.88
- v0.1.87
- v0.1.86
- v0.1.85
- v0.1.84
- v0.1.83
- v0.1.82
- v0.1.81
- v0.1.80
- v0.1.79
- v0.1.78
- v0.1.77
- v0.1.76
- v0.1.75
- v0.1.74
- v0.1.73
- v0.1.72
- v0.1.71
- v0.1.70
- v0.1.69
- v0.1.68
- v0.1.67
- v0.1.66
- v0.1.64
- v0.1.63
- v0.1.62
- v0.1.61
- v0.1.60
- v0.1.59
- v0.1.58
- v0.1.57
- v0.1.56
- v0.1.55
- v0.1.54
- v0.1.53
- v0.1.52
- v0.1.51
- v0.1.50
- v0.1.49
- v0.1.48
- v0.1.47
- v0.1.46
- v0.1.45
- v0.1.44
- v0.1.43
- v0.1.42
- v0.1.41
- v0.1.40
- v0.1.39
- v0.1.38
- v0.1.37
- v0.1.36
- v0.1.35
- v0.1.34
- v0.1.33
- v0.1.32
- v0.1.31
- v0.1.30
- v0.1.29
- v0.1.28
- v0.1.27
- v0.1.26
- v0.1.25
- v0.1.24
- v0.1.23
- v0.1.22
- v0.1.21
- v0.1.20
- v0.1.19
- v0.1.18
- v0.1.17
- v0.1.16
- v0.1.15
- v0.1.14
- v0.1.13
- v0.1.12
- v0.1.11
- v0.1.10
- v0.1.9
- v0.1.8
- v0.1.7
- v0.1.6
- v0.1.5
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.1
- v0.0.100
- v0.0.99
- v0.0.98
- v0.0.97
- v0.0.96
- v0.0.95
- v0.0.94
- v0.0.93
- v0.0.92
- v0.0.91
- v0.0.90
- v0.0.89
- v0.0.88
- v0.0.87
- v0.0.86
- v0.0.85
- v0.0.84
- v0.0.83
- v0.0.82
- v0.0.81
- v0.0.80
- v0.0.79
- v0.0.78
- v0.0.77
- v0.0.76
- v0.0.75
- v0.0.74
- v0.0.73
- v0.0.72
- v0.0.71
- v0.0.70
- v0.0.69
- v0.0.68
- v0.0.67
- v0.0.66
- v0.0.65
- v0.0.64
- v0.0.63
- v0.0.62
- v0.0.61
- v0.0.60
- v0.0.59
- v0.0.58
- v0.0.57
- v0.0.56
- v0.0.55
- v0.0.54
- v0.0.53
- v0.0.52
- v0.0.51
- v0.0.50
- v0.0.49
- v0.0.48
- v0.0.47
- v0.0.46
- v0.0.45
- v0.0.44
- v0.0.43
- v0.0.42
- v0.0.41
- v0.0.40
- v0.0.39
- v0.0.38
- v0.0.37
- v0.0.36
- v0.0.35
- v0.0.34
- v0.0.33
- v0.0.32
- v0.0.31
- v0.0.30
- v0.0.29
- v0.0.28
- v0.0.27
- v0.0.26
- v0.0.25
- v0.0.24
- v0.0.23
- v0.0.22
- v0.0.21
- v0.0.20
- v0.0.19
- v0.0.18
- v0.0.17
- v0.0.16
- v0.0.15
- v0.0.14
- v0.0.13
- v0.0.12
- v0.0.11
- v0.0.10
- v0.0.9
- v0.0.8
- v0.0.7
- v0.0.6
- v0.0.5
- v0.0.4
- v0.0.2
- dev-main
This package is auto-updated.
Last update: 2026-04-02 16:24:20 UTC
README
Tina4 PHP
This Is Now A 4Framework
54 built-in features. Zero dependencies. One require, everything works.
Documentation • Quick Start • Features • CLI Reference • tina4.com
Quick Start
# Install composer require tina4stack/tina4php # Create entry point echo '<?php require "vendor/autoload.php"; (new Tina4\App())->start();' > index.php # Create .env echo 'TINA4_DEBUG=true' > .env # Run php -S localhost:7146 index.php
Open http://localhost:7146 -- your app is running.
What's Built In (54 Features)
Every feature is built from scratch -- no bloated vendor trees, no third-party runtime dependencies in core.
| Category | Features |
|---|---|
| Core HTTP (7) | Router with path params ({id:int}, {p:path}), Server, Request/Response, Middleware pipeline, Static file serving, CORS |
| Database (6) | SQLite, PostgreSQL, MySQL, MSSQL, Firebird -- unified adapter, connection pooling, query cache, transactions, race-safe ID generation, SQL dialect translation |
| ORM (7) | Active Record with typed fields, relationships (has_one/has_many/belongs_to), soft delete, QueryBuilder + MongoDB support, Auto-CRUD generator, migrations with rollback |
| Auth & Security (5) | JWT (HS256/RS256), password hashing (PBKDF2-SHA256), API key validation, rate limiting, CSRF form tokens |
| Templating (3) | Frond engine (Twig/Jinja2-compatible, pre-compiled 2.8x faster), SCSS auto-compilation, built-in CSS (~24 KB) |
| API & Integration (5) | HTTP client (zero-dep), GraphQL with ORM auto-schema + GraphiQL IDE, WSDL/SOAP with auto WSDL, WebSocket (RFC 6455) + Redis backplane, MCP server (24 dev tools) |
| Background (3) | Job queue (File/RabbitMQ/Kafka/MongoDB) with priority, delay, retry, dead letters -- service runner -- event system (on/emit/once/off) |
| Data & Storage (4) | Session (File/Redis/Valkey/MongoDB/DB), response cache (LRU, TTL), seeder + 50+ fake data generators, messenger (SMTP/IMAP) |
| Developer Tools (7) | Dev dashboard (11 tabs), dev toolbar, error overlay (Catppuccin Mocha), dev mailbox, hot reload + CSS hot-reload, code metrics (complexity, coupling, maintainability), AI context installer (7 tools) |
| Utilities (7) | DI container (transient + singleton), HtmlElement builder, inline testing (@tests decorator), i18n (6 languages), Swagger/OpenAPI auto-generation, CLI scaffolding (generate model/route/migration/middleware), structured logging |
1,427 tests. Zero dependencies. Full parity across Python, PHP, Ruby, and Node.js.
For full documentation visit tina4.com.
Features
Routing
use Tina4\Router; use Tina4\Request; use Tina4\Response; Router::get("/api/items", function (Request $request, Response $response) { return $response(["items" => []], HTTP_OK); }); Router::post("/api/webhook", function (Request $request, Response $response) { return $response(["ok" => true], HTTP_OK); })->noAuth();
Path parameters: {id}, {name}, {slug}. Middleware chaining with ->middleware([...]). Chain ->secure() to protect GET routes, ->noAuth() to make routes public.
ORM
class User extends \Tina4\ORM { public $tableName = "users"; public $primaryKey = "id"; public $softDelete = true; public $id; public $name; public $email; public $hasMany = [["Order" => "userId"]]; public $hasOne = [["Profile" => "userId"]]; public $belongsTo = [["Customer" => "customerId"]]; } $user = new User($request); $user->save(); $user->load("email = 'alice@example.com'"); $user->delete(); $users = (new User())->select("*", 100)->asArray();
Database
Unified interface via Database::create():
use Tina4\Database\Database; $db = Database::create('sqlite:///app.db'); $db = Database::create('postgres://localhost:5432/mydb', username: 'user', password: 'pass'); $db = Database::create('mysql://localhost:3306/mydb', username: 'root', password: 'secret'); $db = Database::create('mssql://localhost:1433/mydb', username: 'sa', password: 'pass'); $db = Database::create('firebird://localhost:3050/path/to/db.fdb', username: 'SYSDBA', password: 'masterkey'); $result = $db->fetch("SELECT * FROM users WHERE age > ?", [18]);
JWT Authentication
$token = \Tina4\Auth::getToken(["user_id" => 42], "your-secret"); $payload = \Tina4\Auth::validToken($token, "your-secret"); $claims = \Tina4\Auth::getPayload($token);
POST/PUT/PATCH/DELETE routes require Authorization: Bearer <token> by default.
Sessions
// File, Redis, Valkey, MongoDB, or database-backed sessions $_SESSION["user_id"] = 42; $userId = $_SESSION["user_id"];
Configure via .env:
TINA4_SESSION_HANDLER=redis TINA4_SESSION_PATH=redis://localhost:6379
Queues
use Tina4\Queue; $queue = new Queue(); $queue->push("email.send", ["to" => "alice@example.com", "subject" => "Welcome"]); $queue->push("report.generate", ["id" => 42], priority: 10, delay: 60); // Process jobs $queue->process("email.send", function ($job) { sendEmail($job["to"], $job["subject"]); });
Backends: File (default), RabbitMQ, Kafka, MongoDB. Supports priority, delay, retry, and dead letters.
GraphQL
// Auto-schema from ORM models -- no configuration needed // GET /graphql -> GraphiQL IDE // POST /graphql -> Execute queries // Query: { users { id, name, email } } // Mutation support via ORM save/delete
WebSocket
use Tina4\WebSocket; $ws = new WebSocket('0.0.0.0', 8080); $ws->on('message', function ($connection, $message) { $connection->send("Echo: " . $message); }); $ws->on('open', function ($connection) { $connection->send("Welcome!"); }); $ws->start();
Supports RFC 6455, per-path routing, connection manager, broadcast, and Redis backplane for horizontal scaling.
Swagger / OpenAPI
Auto-generated at /swagger:
/** * @description Get all users * @tags Users */ Router::get("/api/users", function (Request $request, Response $response) { return $response((new User())->select("*", 100)->asArray(), HTTP_OK); });
Event System
use Tina4\Events; Events::on("user.created", function ($user) { sendWelcomeEmail($user); }, priority: 10); Events::once("app.boot", function () { warmCaches(); }); Events::emit("user.created", $userData); Events::off("user.created");
WSDL / SOAP
// Auto WSDL generation from annotated service classes // Endpoint: /wsdl
REST Client
$api = new \Tina4\Api("https://api.example.com", "Bearer xyz"); $result = $api->sendRequest("/users/42"); $result = $api->sendRequest("/users", "POST", ["name" => "Alice"]);
Seeder & Fake Data
use Tina4\FakeData; $fake = new FakeData(); $fake->name(); // "Alice Johnson" $fake->email(); // "alice.johnson@example.com" $fake->phone(); // "+1-555-0123" $fake->address(); // "123 Main St, Springfield" $fake->paragraph(); // Lorem ipsum...
50+ generators for names, emails, addresses, dates, numbers, text, and more.
Messenger (SMTP/IMAP)
use Tina4\Messenger; $messenger = new Messenger(); $messenger->sendEmail( "recipient@example.com", "Subject Line", "<h1>Hello</h1><p>Message body</p>" );
Configure via .env:
SMTP_HOST=smtp.example.com SMTP_PORT=587 SMTP_USERNAME=user@example.com SMTP_PASSWORD=secret
Template Engine (Frond)
Twig-compatible with pre-compilation for 2.8x faster rendering:
{% extends "base.twig" %}
{% block content %}
<h1>{{ title | upper }}</h1>
{% for item in items %}
<p>{{ item.name }} -- {{ item.price | number_format(2) }}</p>
{% endfor %}
{% include "partials/sidebar.twig" %}
{% endblock %}
DI Container
$container = new \Tina4\Container(); $container->singleton('db', fn() => Database::create(getenv('DB_URL'))); $container->register('mailer', fn() => new MailService()); $db = $container->get('db'); // same instance every time $mailer = $container->get('mailer'); // new instance each time
Inline Testing
/** * @tests * assert (1,1) === 2, "1 + 1 = 2" * assert is_integer(1,1) === true, "This should be an integer" */ function add($a, $b) { return $a + $b; }
i18n (Localization)
JSON translation files with placeholder interpolation. Supports 6 languages out of the box.
use Tina4\I18n; $i18n = new I18n('en'); echo $i18n->translate("welcome.message", ["name" => "Alice"]);
HtmlElement Builder
extract(\Tina4\HtmlElement::helpers()); echo $_div(["class" => "card"], $_h2("Title"), $_p("Content") );
Dev Mode
Set TINA4_DEBUG=true in .env to enable:
- Dev dashboard (
/__dev/) -- 11-tab admin UI with route inspection, query runner, queue management, WebSocket monitor, dev mailbox, and more - Dev toolbar -- fixed bar showing HTTP method, matched route, request ID, and PHP version
- Error overlay -- syntax-highlighted stack traces with Catppuccin Mocha theme
- Hot reload -- auto-reload on file changes + CSS hot-reload
- Template debug --
{{ dump(variable) }}available, no caching
CLI Reference
bin/tina4php serve [port] # Start dev server (default: 7146) bin/tina4php migrate # Run pending migrations bin/tina4php migrate:create "description" # Create a migration file bin/tina4php generate model <name> # Generate ORM model scaffold bin/tina4php generate route <name> # Generate route scaffold bin/tina4php generate migration <desc> # Generate migration file bin/tina4php generate middleware <name> # Generate middleware scaffold bin/tina4php seed # Run database seeders bin/tina4php ai [--all] # Install AI context files
Or via Composer:
composer start # Start dev server composer start --production # Start with OPcache + production config composer test # Run test suite composer tina4 migrate # Run migrations composer tina4 generate model User # Scaffold a model
Performance
Benchmarked with wrk — 5,000 requests, 50 concurrent, median of 3 runs:
| Framework | JSON req/s | Deps | Features |
|---|---|---|---|
| Tina4 PHP | 29,293 | 0 | 54 |
| Slim | 5,714 | 10+ | ~6 |
| Laravel | 445 | 50+ | ~25 |
Tina4 PHP is 5× faster than Slim and 65× faster than Laravel — with zero dependencies and 54 features built in.
Across all 4 Tina4 implementations:
| Python | PHP | Ruby | Node.js | |
|---|---|---|---|---|
| JSON req/s | 6,508 | 29,293 | 10,243 | 84,771 |
| Dependencies | 0 | 0 | 0 | 0 |
| Features | 54 | 54 | 54 | 54 |
Cross-Framework Parity
Tina4 ships the same 54 features across four languages with full test parity:
| Language | Package | Tests |
|---|---|---|
| Python | pip install tina4 |
1,427 |
| PHP | composer require tina4stack/tina4php |
1,427 |
| Ruby | gem install tina4 |
1,427 |
| Node.js | npm install tina4 |
1,427 |
Same routing, same ORM, same templates, same CLI, same dev tools. Learn one, deploy in any.
Environment
Key .env variables:
# Core TINA4_DEBUG=true # Enable debug mode DATABASE_PATH=app.db # SQLite database path (or use DATABASE_URL) DATABASE_URL=postgres://localhost/mydb # Connection URL for any database SECRET=your-jwt-secret # JWT signing secret TINA4_LOCALE=en # Localization language # Database TINA4_DB_CACHE=true # Enable query caching (4x speedup) TINA4_AUTOCOMMIT=false # Auto-commit control (default: off) # Sessions TINA4_SESSION_HANDLER=file # file, redis, valkey, mongodb, database TINA4_SESSION_PATH=redis://localhost # Session backend URL TINA4_SESSION_SAMESITE=Lax # SameSite cookie attribute # Cache TINA4_CACHE_TTL=60 # Response cache TTL in seconds TINA4_CACHE_MAX_ENTRIES=1000 # Max cached responses # WebSocket TINA4_WS_BACKPLANE=redis # WebSocket scaling backplane TINA4_WS_BACKPLANE_URL=redis://localhost # Backplane connection URL # Swagger SWAGGER_TITLE=My API # Swagger page title SWAGGER_DESCRIPTION=API docs # Swagger description # SMTP SMTP_HOST=smtp.example.com # Mail server SMTP_PORT=587 # Mail port SMTP_USERNAME=user@example.com # Mail username SMTP_PASSWORD=secret # Mail password
Zero-Dependency Philosophy
Tina4 PHP is built from the ground up with no third-party runtime dependencies in core. The framework requires only PHP 8.2+ with openssl and json extensions. Database drivers are optional and installed separately. This keeps the full deployment under 8 MB and minimizes your project's carbon footprint.
Documentation
Full guides, API reference, and examples at tina4.com.
License
MIT (c) 2007-2026 Tina4 Stack https://opensource.org/licenses/MIT
Tina4 -- The framework that keeps out of the way of your coding.
Our Sponsors
Sponsored with 💙 by Code Infinity
Supporting open source communities Innovate Code Empower*