inkphp GitHub 中文

Command line: bin/ink

CommandWhat it does
php bin/ink serve [port]development server (default 8000, APP_ENV=dev)
php bin/ink routesevery URL with its file, param count, methods and login requirement
php bin/ink checksyntax, page declarations and security rules; exit code 1 on errors
php bin/ink test [--http=URL]runs the route tables in tests/*.txt; --http tests a running server
php bin/ink migrateapplies migrations/*.sql in order

What check looks for (excerpt)

Route tables

tests/app.txt# tests/app.txt
GET   /                 -> 200 pages/index.php []
GET   /about.php        -> 301 /about
GET   /user/42          -> 200 pages/user.php ["42"]
GET   /user/01          -> http:404        # decided by the page: checked with --http only
POST  /about            -> 405

Your own CLI scripts

bin/import-users#!/usr/bin/env php
<?php
// bin/import-users — php bin/import-users users.csv
require __DIR__ . '/../ink/ink.php';     // in the CLI: no headers; uncaught exceptions go to STDERR, exit code 1
$n = 0;
tx(function () use (&$n): void {
    foreach (new SplFileObject($GLOBALS['argv'][1]) as $line) {
        if (trim((string) $line) === '') continue;
        q('INSERT INTO users (name) VALUES (?)', [trim((string) $line)]);
        $n++;
    }
});
log_info('users imported', ['rows' => $n]);

Run them as the web user (sudo -u www-data php bin/…) and commit large imports in batches.