Repository navigation
PHP Library
The helper is Server/PHP/lib/Display.php. It uses enums and readonly classes, so use PHP 8.2 or newer. Imagick is required for image conversion and raster text; plain drawing-command generation does not need to instantiate an image.
Save this as a PHP file in Server/PHP/sample/:
<?php
require_once __DIR__ . '/../lib/Display.php';
$display = new Display();
$display
->clear(Color::WHITE)
->text(new TextBox(
x: 20,
y: 20,
width: 740,
height: 70,
spans: [new TextSpan(
text: 'Hello, JSON Paper!',
family: 'helvetica',
size: 32,
color: Color::BLACK
)]
));
$display->output();output() sets Content-Type: application/json and emits protocol 2.0. array() returns the document structure, while json() serializes it and enforces the 128 KiB limit. If you serialize array() yourself, check the final response size yourself.
The explicit family is intentional: the committed PHP TextSpan default is sans, while the bundled device family is helvetica.
| Method | Command |
|---|---|
clear() |
clear |
clearWindow() |
clear_window |
point() |
draw_point |
line() |
draw_line |
rectangle() |
draw_rectangle |
circle() |
draw_circle |
pieSlice() |
draw_pie_slice |
text() |
draw_text |
image() |
draw_image |
rasterText() |
Server-rasterized text emitted as draw_image |
Colors and styles use Color, Width, LineStyle, PointStyle, and FillMode enums. Text uses TextBox, TextSpan, FontWeight, alignment enums, and TextOverflow. Library validation and accepted fields do not imply that every layout feature is implemented by the device; see Draw Text.
image(x, y, Imagick $img, Color $transparent) converts an image to packed palette pixels; the transparency selector defaults to Color::TRANSPARENT. rasterText() uses a RasterFontFamily containing regular and bold server-side font paths.
From the repository root:
php -S 127.0.0.1:8080 -t Server/PHP/sampleLoad the endpoint in the Emulator. To reach a development server from the physical device, bind it to a reachable local-network interface and use that computer's LAN address; the device's localhost is not your computer.
The dashboard samples may use additional image/font assets. The minimal endpoint above only requires the helper files.