inkphp GitHub 中文

Quick start

PHP 8.2+ (8.4 recommended) with pdo, mbstring, fileinfo (and pdo_sqlite for the examples). No web server needed while developing.

git clone https://github.com/JackWuGlobal/inkphp.git && cd inkphp   # or download https://github.com/JackWuGlobal/inkphp/archive/refs/heads/main.zip
php bin/ink migrate        # run migrations/*.sql (the examples use SQLite: storage/db.sqlite)
php bin/ink serve          # http://127.0.0.1:8000

Your first page

pages/hello.php → /hello<?php
params();                         // this page takes no extra URL segments
$name = $_GET['name'] ?? 'world';
layout('site', ['title' => 'Hello']);
?>
<h1>Hello, <?= e($name) ?></h1>
pages/user.php → /user/42<?php
[$raw] = params(1);               // /user/42 → '42'; /user and /user/1/2 → 404
$id = as_id($raw);                // canonical positive ids only: '01', 'abc' → 404
$u = one('SELECT name FROM users WHERE id = ?', [$id]) ?? abort(404);
?>
<h1><?= e($u['name']) ?></h1>

After every change

php bin/ink check      # syntax, page declarations, security rules
php bin/ink routes     # every URL and its file
php bin/ink test       # route tables in tests/*.txt