A PHP 7.3+ and PHP 8.x compliant port of the Sutton SignWriting Core for Python, focused on Formal SignWriting in ASCII (FSW), SignWriting in Unicode (SWU), FSW and SWU query languages, style strings, and conversion utilities.
Core utilities for Formal SignWriting (FSW/SWU): conversion, queries, and style strings.
composer require sutton-signwriting/core- PHP 7.3+
mbstringextension required for Unicode-safe operations- For running tests locally:
dom,xml, andxmlwriterextensions (or use Docker Compose)
<?php
require __DIR__ . '/vendor/autoload.php';
use function Sgnw\Core\Convert\fsw_to_swu;
use function Sgnw\Core\Fsw\fsw_parse_sign;
$swu = fsw_to_swu('AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475');
$sign = fsw_parse_sign('AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475');<?php
require __DIR__ . '/src/Functions/convert.php';
require __DIR__ . '/src/Functions/style.php';
require __DIR__ . '/src/Functions/fsw.php';
require __DIR__ . '/src/Functions/fswquery.php';
require __DIR__ . '/src/Functions/swu.php';
require __DIR__ . '/src/Functions/swuquery.php';
// Example: parse an FSW sign
$sign = fsw_parse_sign('AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475');
// Example: convert FSW to SWU
$swu = fsw_to_swu('AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475');
// Example: parse an SWU sign
$sign = swu_parse_sign('๐ ๑๑๑ฅ๑ฉ๐ ๐ค๐คฉ๑ฉ๐ฃต๐ค๑๐ค๐ฃค๑ฅ๐ค๐ค๑๐ฃฎ๐ฃญ');
// Example: build an SWU query from a sign
$query = swu_to_query($sign, 'ASL');- Online docs: https://www.sutton-signwriting.io/core-php
- Local generation:
composer docs(ordocker compose run --rm core-php composer docs) writes output todocs/(generated output, not committed). - Local preview: run
composer docs, thendocker compose up --build docsand open http://localhost:8090 - CI publishing: on push to
main, GitHub Actions generatesdocs/and publishes it to GitHub Pages (see.github/workflows/docs.yml).- In GitHub: Settings โ Pages โ Build and deployment โ Source = โGitHub Actionsโ.
This repo includes a docker-compose.yml for a reproducible PHP 7.3 environment.
Start the services (foreground, with build):
docker compose up --build # core-php and doc server
docker compose up --build core-php # core-php without doc serverIn another terminal, run actions inside the running core-php container:
docker compose exec core-php composer test # run tests
docker compose exec core-php composer docs # rebuild docsRun a command in a fresh throwaway container (good for CI-like tasks):
docker compose run --rm core-php composer test
docker compose run --rm core-php composer docs- A Compose service is a named definition in
docker-compose.yml(e.g.core-php,docs). - A container is a running instance created from a service definition.
docker compose upcreates/starts the service containers and keeps them running.docker compose execruns a command in an already-running service container.docker compose run --rmcreates a new one-off container for that command and deletes it when finished.- If you want to start everything together, use
docker compose up --build(no service name). - When running
docker compose upwithout-d, leave it running and use another terminal forexec.
Shut everything down:
docker compose downPublic entrypoints (Composer autoload):
src/convert.phpsrc/fsw.phpsrc/fswquery.phpsrc/regex.phpsrc/swu.phpsrc/swuquery.phpsrc/style.php
Optional global wrappers (not autoloaded):
src/Functions/*.php(explicitrequire_onceper file)
If you already have PHP 7.3+ available locally:
composer install
composer test
composer docsvendor/bin/phpunit --testdoxMIT