Papercut
Guide
Laravel
Reference
Examples
Changelog
GitHub
Guide
Laravel
Reference
Examples
Changelog
GitHub

Examples

The repository includes four example documents, each written twice: once as a Blade view and once in plain PHP. Comparing the two versions is a good way to see how Blade tags map to the PHP API.

DocumentWhat it showsBladePHP
Invoicea letterhead row, a tinted panel, line items, right-aligned totals, a footerinvoice.blade.phpinvoice.php
Transcripta sixty-row table across pages with its header repeated, keep-together blockstranscript.blade.phptranscript.php
Reportjustified prose, stat cards from an app component, an eighty-row table, a forced page breakreport.blade.phpreport.php
Form responsesall eight decorators: a card of details, a callout, numbered sections, fields, choice lists, rated statements with badges, a blockquoteresponses.blade.phpresponses.php

Running them

From a checkout, install the dependencies for the package you want to try, then run the scripts from the repository root.

# Plain PHP: writes examples/core/<name>.pdf
(cd packages/core && composer install)
php examples/core/invoice.php
php examples/core/transcript.php
php examples/core/report.php
php examples/core/responses.php

# The same documents as HTML: writes examples/html/<name>.html
php examples/html/render.php

# Blade: writes examples/laravel/<name>.pdf and .html
(cd packages/laravel && composer install)
php examples/laravel/render.php

The Blade script spins up a temporary Laravel app with Orchestra Testbench, so you don't need a full Laravel install. The sample data for the views is in examples/laravel/data.php.

The form responses example

This example shows how to build something specific to your app from the decorators. Papercut doesn't know anything about questions or answers. The view just loops over the items and picks a decorator for each one:

@foreach ($items as $item)
  @if ($item['type'] === 'instruction')
    <x-doc::callout type="note" :title="$item['prompt']">{{ $item['text'] }}</x-doc::callout>
    @continue
  @endif

  <x-doc::section :number="++$n" :title="$item['prompt']" rule keep-together>
    @switch($item['type'])
      @case('text')
        <x-doc::field placeholder="No response" lines="2">{{ $item['answer'] }}</x-doc::field>
        @break
      @case('choices')
        <x-doc::choices :type="$item['multiple'] ? 'checkbox' : 'radio'" emphasize-selected>
          @foreach ($item['options'] as $option)
            <x-doc::choice :selected="in_array($option, $item['selected'], true)">{{ $option }}</x-doc::choice>
          @endforeach
        </x-doc::choices>
        @break
    @endswitch
  </x-doc::section>
@endforeach

An unanswered question shows "No response" in a grey box rather than leaving a gap, and selected options get a filled checkbox and a bold label. All the colours come from the theme, so the form matches every other document the app produces.

Edit this page on GitHub
Last Updated: 10/21/26, 1:31 PM