# robgridley/zebra architecture

> Architecture diagram of the GitHub repository robgridley/zebra, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/robgridley/zebra
- Repository: https://github.com/robgridley/zebra

## Overview

Zebra is a small PHP library for building ZPL labels, converting images for ZPL graphics, and sending ZPL to a networked Zebra printer. In the documented workflow, the caller loads an image through GdDecoder, wraps it as a ZPL image, adds it to a Builder, then sends the generated ZPL through Client. Source confirms the decoder/image and builder/image calls; the README supplies the overall usage flow. The graph omits unverified implementation details of unsampled paths.

Main entry points: [`src/Zpl/Image.php`](https://github.com/robgridley/zebra/blob/master/src/Zpl/Image.php) (ZPL image), [`src/Zpl/GdDecoder.php`](https://github.com/robgridley/zebra/blob/master/src/Zpl/GdDecoder.php) (GD decoder), [`src/Zpl/Builder.php`](https://github.com/robgridley/zebra/blob/master/src/Zpl/Builder.php) (ZPL builder), [`src/Client.php`](https://github.com/robgridley/zebra/blob/master/src/Client.php) (Printer client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_image["Image conversion"]
  node_gd_decoder["GD decoder<br/>[GdDecoder.php]"]
  node_zpl_image["ZPL image<br/>[Image.php]"]
end

subgraph group_zpl["ZPL building"]
  node_builder["ZPL builder<br/>[Builder.php]"]
end

subgraph group_transport["Printer transport"]
  node_client["Printer client<br/>[Client.php]"]
end

node_caller(("Application"))
node_gd_extension["PHP GD"]
node_printer(("Zebra printer"))

node_caller -->|"loads image"| node_gd_decoder
node_gd_decoder -->|"decodes pixels"| node_gd_extension
node_caller -->|"wraps decoder"| node_zpl_image
node_zpl_image -->|"reads dimensions"| node_gd_decoder
node_zpl_image -->|"reads pixels"| node_gd_decoder
node_caller -->|"adds commands"| node_builder
node_builder -->|"reads image data"| node_zpl_image
node_caller -->|"sends ZPL"| node_client
node_client -->|"writes TCP"| node_printer

click node_gd_decoder "https://github.com/robgridley/zebra/blob/master/src/Zpl/GdDecoder.php"
click node_zpl_image "https://github.com/robgridley/zebra/blob/master/src/Zpl/Image.php"
click node_builder "https://github.com/robgridley/zebra/blob/master/src/Zpl/Builder.php"
click node_client "https://github.com/robgridley/zebra/blob/master/src/Client.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_gd_decoder,node_zpl_image toneBlue
class node_builder toneAmber
class node_client toneMint
class node_caller,node_gd_extension,node_printer toneIndigo
```

## Components

### Image conversion

- [GD decoder](https://github.com/robgridley/zebra/blob/master/src/Zpl/GdDecoder.php): `src/Zpl/GdDecoder.php`
- [ZPL image](https://github.com/robgridley/zebra/blob/master/src/Zpl/Image.php): `src/Zpl/Image.php`

### ZPL building

- [ZPL builder](https://github.com/robgridley/zebra/blob/master/src/Zpl/Builder.php): `src/Zpl/Builder.php`

### Printer transport

- [Printer client](https://github.com/robgridley/zebra/blob/master/src/Client.php): `src/Client.php`

### Other components

- **Application**
- **PHP GD**
- **Zebra printer**

## Connections

- Application → GD decoder: loads image
- GD decoder → PHP GD: decodes pixels
- Application → ZPL image: wraps decoder
- ZPL image → GD decoder: reads dimensions
- ZPL image → GD decoder: reads pixels
- Application → ZPL builder: adds commands
- ZPL builder → ZPL image: reads image data
- Application → Printer client: sends ZPL
- Printer client → Zebra printer: writes TCP
