tina4stack/tina4-php
tina4stack/tina4-php has 28 GitHub stars and 22 forks. Star changes are not measured yet. Last checked 2026-11-14 02:42 UTC. Last push 2026-11-13.
What you can do
- 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/HS384/HS512 via core hash_hmac, no extension; RS256 opt-in via suggested ext-openssl), password hashing (PBKDF2-SHA256), API key validation, rate limiting, CSRF form tokens
측정된 스타 증가
- in 24h
- 기록 수집 중
- in 7 days
- 기록 수집 중
- in 15 days
- 기록 수집 중
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
소개
Tina4 PHP composer repository
데이터README.md
Original
Tina4 PHP
The Intelligent Native Application 4ramework
140 cataloged features. Zero dependencies. One require, everything works.
Documentation • Quick Start • Features • CLI Reference • tina4.com
Quick Start
# Install the Tina4 CLI (one-time, cross-language)
cargo install tina4 # or download a binary from https://github.com/tina4stack/tina4/releases
# Create a project
tina4 init php ./my-app
# Run it
cd my-app && tina4 serve
Open http://localhost:7145 -- your app is running.
Without the Tina4 CLI
# 1. Install
composer require tina4stack/tina4php
# 2. Entry point
echo '<?php require "vendor/autoload.php"; (new Tina4\App())->run();' > index.php
# 3. .env
echo 'TINA4_DEBUG=true' > .env
# 4. Run (no file watching in this mode)
composer start
What's Built In (140 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/HS384/HS512 via core hash_hmac, no extension; RS256 opt-in via suggested ext-openssl), 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 |
2,073 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 = '[email protected]'");
$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" => "[email protected]", "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"]);
AI Client
use Tina4\AI;
$reply = AI::chat([["role" => "user", "content" => "Summarise this text"]]);
$text = AI::complete("Give me a title");
$vector = AI::embed("semantic search text");
foreach (AI::chat([["role" => "user", "content" => "Stream this"]], stream: true) as $delta) {
echo $delta;
}
Configure TINA4_AI_PROVIDER as local, openai, or anthropic. Hosted providers require TINA4_AI_KEY; local OpenAI-compatible endpoints do not. The AI context/skills installer is Tina4\AITools.
Seeder & Fake Data
use Tina4\FakeData;
$fake = new FakeData();
$fake->name(); // "Alice Johnson"
$fake->email(); // "[email protected]"
$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(
"[email protected]",
"Subject Line",
"<h1>Hello</h1><p>Message body</p>"
);
Configure via .env:
SMTP_HOST=smtp.example.com
SMTP_PORT=587
[email protected]
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/) -- 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 -- the
tina4Rust CLI watchessrc/,migrations/,.envand POSTs/__dev/api/reload; PHP broadcasts to the browser via WebSocket (/__dev_reload) with a polling fallback onGET /__dev/api/mtime. SCSS changes swap the stylesheet without a full reload - Template debug --
{{ dump(variable) }}available, no caching
CLI Reference
bin/tina4php serve [--port P] [--host H] # Start dev server (default: 0.0.0.0:7145)
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 | 55 |
| 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 140 cataloged 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 | 55 | 55 | 55 | 55 |
Cross-Framework Parity
Tina4 ships the same 140 cataloged features across four languages with full test parity:
| Language | Package | Tests (v3.11.12) |
|---|---|---|
| Python | pip install tina4-python |
2,281 |
| PHP | composer require tina4stack/tina4php |
2,073 |
| Ruby | gem install tina4 |
2,508 |
| Node.js | npm install @tina4/core |
2,897 |
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 TINA4_DATABASE_URL)
TINA4_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)
TINA4_DATABASE_CONNECT_TIMEOUT=10 # Seconds to wait for a connect (0 or less = wait forever)
# 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
[email protected] # 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.
Demo Store
A complete e-commerce app lives in example/. It demonstrates every framework feature through a real-world use case.
cd example
bash setup.sh # macOS/Linux
# or: setup.bat # Windows
php index.php
| Role | Password | |
|---|---|---|
| Admin | [email protected] | admin123 |
| Customer | [email protected] | customer123 |
See example/README.md for full details.
Documentation
Full guides, API reference, and examples at tina4.com.
License
MPL-2.0. Copyright (c) 2026 Code Infinity. Separate commercial terms are available from Code Infinity. Previously published releases retain their original licences. https://mozilla.org/MPL/2.0/
Tina4: The Intelligent Native Application 4ramework
Simple. Fast. Human. · Built for AI. Built for you.
Our Sponsors
Sponsored with :blue_heart: by Code Infinity
Supporting open source communities Innovate Code Empower*
관련 프로젝트 살펴보기
Asabeneh/30-Days-Of-Python
30 Days of Python 프로그래밍 챌린지는 Python 프로그래밍 언어를 30일 동안 배우기 위한 단계별 가이드입니다. 이 챌린지는 100일 이상 걸릴 수 있습니다. 자신의 속도에 맞춰 진행하세요. 다음 동영상도 도움이 될 수 있습니다: https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw
78,711 스타grafana/grafana
개방적이고 조합 가능한 옵저버빌리티 및 데이터 시각화 플랫폼입니다. Prometheus, Loki, Elasticsearch, InfluxDB, Postgres 등 여러 소스의 메트릭, 로그, 트레이스를 시각화합니다.
77,894 스타redis/redis
실시간 데이터 기반 애플리케이션을 구축하는 개발자에게 Redis는 가장 선호되고, 가장 빠르며, 기능이 가장 풍부한 캐시, 데이터 구조 서버이자 문서 및 벡터 쿼리 엔진입니다.
77,490 스타apache/superset
Apache Superset는 데이터 시각화 및 데이터 탐색 플랫폼입니다.
75,522 스타