sutton-signwriting / core
Core utilities for Formal SignWriting (FSW/SWU): conversion, queries, and style strings.
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/sutton-signwriting/core
Requires
- php: ^7.3 || ^8.0
- ext-mbstring: *
Requires (Dev)
- ext-dom: *
- ext-xml: *
- ext-xmlwriter: *
- phpunit/phpunit: ^9.5
README
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.
Install (Composer)
composer require sutton-signwriting/core
Requirements
- PHP 7.3+
mbstringextension required for Unicode-safe operations- For running tests locally:
dom,xml, andxmlwriterextensions (or use Docker Compose)
Usage
With Composer (recommended)
<?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');
Without Composer (direct include)
<?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');
Documentation
- 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โ.
Development (Docker Compose)
This repo includes a docker-compose.yml for a reproducible PHP 7.3 environment.
Path A: action flow (up + exec)
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 server
In 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 docs
Path B: one-off actions (run --rm)
Run 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
Notes: service vs container
- 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 down
Structure
Public 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)
Local development (no Docker)
If you already have PHP 7.3+ available locally:
composer install
composer test
composer docs
More verbose test output
vendor/bin/phpunit --testdox
License
MIT