Skip to content

0.1.0

Choose a tag to compare

@amermmohammed amermmohammed released this 27 Nov 22:12
· 113 commits to main since this release

Turn one PHP script into an internal tool with a web page. You write no HTML, no JavaScript, no controller and no template.

composer require runio/script-ui

The readme shows a first tool, every function, and how to put the tools behind the login of your own application.

First version. Requires PHP 8.2+ with the mbstring and session extensions, and no other package.

Added

  • A tool is one PHP script. It runs from top to bottom and runs again on every interaction.
  • Text and messages: title, heading, note, code, json, link, divider, metric, success, info, warning, error.
  • Inputs that return their current value: text, textarea, number, select, checkbox, date_input.
  • radio shows every option and takes one. multiselect shows a tick box for every option and returns the ticked ones as a list. Both take their options the way select does, lay them out in a column, in several columns or in a row (horizontal: true), and can be filled in by a link.
  • table with sorting, pages (pageSize:), a search box (search: true) and rows you can tick on any page, one by one or a page at a time. chart with bar and line charts drawn as SVG.
  • button with an optional question before it acts, plus columns, stop and rerun.
  • expander puts a part of the page under a line that opens and closes it, and tabs puts parts behind headers with one of them in view. What is out of sight still runs: the inputs inside keep working, and opening a part or changing the tab needs no run of the tool. The page remembers what was left open.
  • refresh lets a page run again by itself every few seconds, for dashboards and queues. It waits while the user is in the middle of something, stops while the page is out of sight or nobody is there, waits longer after failures, and never presses a button or changes what the page remembers.
  • field_error says under an input what is wrong with what it holds, and valid tells whether anything was found wrong. After a pressed button the first wrong input gets the keyboard focus, and an expander or a tab that hides it comes into sight. Screen readers are told that the input is invalid and read the note with it. A file that a file field turns down is marked in the same way and counts for valid. The log entry of a press says what was found wrong.
  • file_input takes files from the user: one or several, with limits on size and kind. A file stays on the server between the runs of a tool, in a folder only PHP reads, and the page names it by a random handle. Upload gives the tool name, size, path, contents(), saveTo() and forget(), and rows() reads an uploaded CSV file as rows, whichever spreadsheet wrote it. uploads: sets the folder, clean_uploads() deletes what was left behind.
  • download hands the user a file: rows as CSV or JSON, or any text. csv writes rows as CSV with a choice of columns and separator. Cells that a spreadsheet would run as a formula are defused.
  • serve() for a folder of tools with an index page, configure() for a script on its own, and the script-ui serve command for local use.
  • A login check and an audit log (auth, log), protection against forged requests, a strict Content-Security-Policy, and local-only access while no login check is set.
  • The help text of an input is read out with the input by software that reads the page.
  • Pages update in place with JavaScript and work as plain forms without it. A title in Arabic or Hebrew turns the page right to left.
  • The library's own texts ("Yes", "Reset", "No rows.") in English, Arabic and German. A page follows the language of its title, language: sets one language for every page, and texts: replaces single texts or adds a language.