background

Durable Laravel Typst

License: MITPHP

A Laravel package that provides a convenient facade for compiling Typst documents directly from your Laravel application. Typst is a modern markup-based typesetting system designed to be simple, powerful, and fast.

Features

Installation

Requirements

Installation Steps

Add the package repository to your composer.json:

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/durableprogramming/durable-laravel-typst"
    }
  ]
}

Install via Composer:

composer require durableprogramming/durable-laravel-typst

Publish the configuration file:

php artisan vendor:publish --tag=typst-config

Usage

Basic Compilation

use DurableProgramming\Typst\Facades\Typst;

// Compile Typst source to PDF
$outputPath = Typst::compile('#set text(font: "Arial")
Hello, World!');

// The compiled PDF is now available at $outputPath

Compile from File

// Compile a Typst file to PDF
$outputPath = Typst::compileFile('/path/to/document.typ');

Custom Output Formats

// Compile to PNG
$outputPath = Typst::compile(
    '#set text(font: "Arial")
    Hello, World!',
    format: 'png'
);

// Compile to SVG
$outputPath = Typst::compile(
    '#set text(font: "Arial")
    Hello, World!',
    format: 'svg'
);

Advanced Usage with Runtime Settings

// Compile with custom settings
$outputPath = Typst::compile(
    '#set text(font: "Arial")
    Hello, World!',
    format: 'pdf',
    settings: [
        'ppi' => 300,
        'font-path' => '/path/to/fonts'
    ]
);

Configuration

After publishing the configuration file, you can customize the package behavior in config/typst.php:

return [
    'binary_path' => env('TYPST_BINARY_PATH', 'typst'),
    'output_path' => storage_path('app/typst'),
    'default_format' => 'pdf',
];

Use Cases

Why Typst?

Typst is a modern alternative to LaTeX that offers:

Development

Testing

composer test

Code Style

composer format

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting pull requests.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Make your changes
  4. Ensure tests pass (composer test)
  5. Commit your changes
  6. Push to your fork
  7. Open a pull request

License

MIT License - see LICENSE.md for details.

Copyright (c) 2025 Durable Programming, LLC. All rights reserved.

Support

For bugs, feature requests, or questions, please open an issue on GitHub.

GitHub

📅 Created September 2025 | 🔄 Updated September 2025

View on GitHub