hook-dev-alter / typst-bin
The typst binary (linux x86-64) packaged for composer, plus a PHP command builder for `typst compile`.
Requires
- php: ^8.3
- symfony/process: ^7.2 || ^8.0
Requires (Dev)
- phpunit/phpunit: ^13.2
This package is not auto-updated.
Last update: 2026-08-26 20:15:30 UTC
README
Provides the typst binary
(licensed Apache-2.0,
currently only linux x86-64)
packaged for Composer, and a PHP command builder for typst compile with
all its args and options, executing via symfony/process.
Installation
composer require geeks4change/typst-bin
This installs the typst binary as a Composer bin (vendor/bin/typst) and
the HOOK_DEV_ALTER\TypstBin PHP classes.
Usage
use HOOK_DEV_ALTER\TypstBin\TypstCompile;
use HOOK_DEV_ALTER\TypstBin\Option\OutputFormat;
$result = TypstCompile::file('document.typ')
->withOutput('document.pdf')
->withFormat(OutputFormat::Pdf)
->run();
if (!$result->isSuccessful()) {
// typst exits non-zero for ordinary compile errors; run() never throws
// for that. $result->errorOutput carries typst's diagnostics.
throw new \RuntimeException($result->errorOutput);
}
TypstCompile is immutable: every with*() method returns a new instance.
toArgs() / toArgv() expose the generated argument list without running
anything, which is what the unit tests assert against.
Supported platform
The packaged binary only supports linux x86-64. On any other platform,
set the TYPST_BIN environment variable to a compatible typst binary
(e.g. a system install, or a build for another architecture); TypstBinary
picks it up automatically before falling back to the packaged binary or the
PATH.
Version policy
The vendored binary's version is recorded in the VERSION file at the
package root. To update it, run:
./build.sh # downloads the latest typst release
./build.sh 0.15.1 # or pin an explicit version
This downloads the linux x86-64 build, replaces bin/typst, updates
VERSION, and commits and tags the result.