Every team that runs a shop or a web application has a list of small jobs that nobody built a screen for. Refund these three orders. Give this customer a coupon. Export the orders of last month for the accountant. The data and the code for each of them are in the application already. What is missing is the page.
In PHP that page is more work than the job itself: a route, a controller, a template, validation, a form token, and some JavaScript as soon as a table should be selectable. So the page does not get built. Somebody gets access to the database instead, or a developer does the job by hand every time.
I wanted the page to cost one file. So I wrote Script UI, a library that turns one PHP script into an internal tool with a web page.
The whole tool is this script
<?php // tools/hello.php
// Hello
// My first tool.
use function Runio\ScriptUi\{title, text, button, success};
title('Hello');
$name = text('Your name');
if (button('Greet') && $name !== '') {
success('Hello, ' . $name . '.');
}

There is no HTML in it, no JavaScript, no controller and no template. Two ideas carry all of it:
- An input returns its value.
text('Your name')draws the field and gives you what the user typed. There is no form to build and no request to read. - A button is an
if.button('Greet')draws the button, and returnstruein the run in which it was pressed.
If you know Streamlit from Python, you know the model. The script runs from top to bottom, and it runs again on every interaction. A click sends the form, the script starts at its first line, and this time text() returns the name and button() returns true. The library sends the new page back, and the browser swaps the content without loading the page again.
I looked for this in PHP before I wrote it. PHP has good admin generators, and it has Livewire and Symfony UX for components that update themselves. I did not find the plain version: a script that is the page.
A real one: refunds
A hello-world proves little. This is a tool of the kind that teams really need:
<?php // tools/refund.php
require __DIR__ . '/../bootstrap.php'; // your app: $db, $refunds
use function Runio\ScriptUi\{title, text, select, table, button, success, rerun};
title('Refund orders');
$email = text('Customer email');
$status = select('Status', ['paid', 'shipped']);
if ($email !== '') {
$orders = $db->fetchAll('SELECT id, total, created_at FROM orders WHERE email = ? AND status = ?', [$email, $status]);
$picked = table($orders, selectable: true);
if ($picked && button('Refund selected', style: 'danger', confirm: 'Refund ' . count($picked) . ' orders?')) {
foreach ($picked as $order) {
$refunds->create($order['id']);
}
success('Refunded ' . count($picked) . ' orders.');
rerun();
}
}

That script is the whole tool: a search field, a filter, a table that sorts and has tick boxes, a button that asks before it acts, and a message when it is done. table() returns the rows that the user ticked. The query and the refund are your own code. The library does not know your database, and it does not want to.
What comes with it
- Tables that select, sort, search and page. For 100,000 rows you pass a function that reads one page from your database.
- Uploads and downloads, charts, numbers with their change, tabs and columns.
- Tasks that take long: a bar shows how far a worker is, and the page keeps itself up to date.
- A place for your own login. You say who is asking and who may open which tool, in plain PHP, in Symfony or in Laravel. Every pressed button can go to your audit log.
- Form tokens, escaping and a strict Content-Security-Policy from the start. Without a login check a tool only answers on your own computer.
- Texts in English, German and Arabic. An Arabic title turns the page from right to left.
It needs PHP 8.2 or newer and no other package.
What it is not
It is for people inside: colleagues behind a login. It is not for the pages of your customers.
It is not an admin generator either. A screen that mostly lists and edits records is a job for EasyAdmin, Filament or Nova, and they do it with far less code. Script UI fits the task with a few inputs, a button and a result. Many teams will use both.
And it is early. Version 0.2 is out, and until version 1.0 a new version may change how a function is called. The changelog says what changed.
Try it
composer require runio/script-ui
php vendor/bin/script-ui serve tools
The second line starts PHP's own server on your computer and lists the scripts of the folder tools.
The website plays one click slowly on its first page, and you can use that page yourself. The first tutorial takes ten minutes, and the examples show the ten tools of a small shop back office with their sources.
The code is on GitHub under the MIT licence, and the package is runio/script-ui on Packagist. If you build a tool with it, I would like to hear what was missing.
In the next post I go through one click step by step: what the browser sends, what the library checks, and why a button can be an if.
Author Amer Malik Mohammed
Full-Stack Developer with 2+ years of experience in object-oriented PHP development (Symfony), JavaScript and MySQL. Specialized in e-commerce solutions (Shopware 5/6), REST API development and process automation in agile teams.
Contact author