PHPackages                             graystackit/laravel-dymo-printer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. graystackit/laravel-dymo-printer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

graystackit/laravel-dymo-printer
================================

A Laravel package for Dymo label printer integration with Livewire support

00PHP

Since May 4Pushed 1mo agoCompare

[ Source](https://github.com/GraystackIT/laravel-dymo-printer)[ Packagist](https://packagist.org/packages/graystackit/laravel-dymo-printer)[ RSS](/packages/graystackit-laravel-dymo-printer/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (2)Used By (0)

graystackit/laravel-dymo-printer
================================

[](#graystackitlaravel-dymo-printer)

A Laravel package for DYMO LabelWriter printer integration with Alpine.js and Livewire support. Provides printer selection persistence, REST API endpoints, and an event-driven JavaScript bridge to the official DYMO JavaScript Framework SDK.

Requirements
------------

[](#requirements)

- PHP 8.3+
- Laravel 11, 12, or 13
- [DYMO Connect](https://www.dymo.com/support/dymo-connect-for-desktop-download.html) installed on client machines
- Livewire 3.x *(optional — only needed for the Livewire printer-select component)*

Installation
------------

[](#installation)

### 1. Install via Composer

[](#1-install-via-composer)

```
composer require graystackit/laravel-dymo-printer
```

The package auto-registers via Laravel's service provider discovery — no manual registration needed.

### 2. Publish Configuration *(optional)*

[](#2-publish-configuration-optional)

```
php artisan vendor:publish --tag=dymo-printer-config
```

### 3. Migrate *(database driver only)*

[](#3-migrate-database-driver-only)

Only required if you plan to use the `database` state driver:

```
php artisan vendor:publish --tag=dymo-printer-migrations
php artisan migrate
```

---

Configuration
-------------

[](#configuration)

KeyDefaultDescription`state_driver``session`How printer selection is persisted: `session`, `cache`, or `database``session_key``dymo_printer_name`Session array key (session driver only)`cache_prefix``dymo_printer`Cache key prefix (cache driver only)`cache_ttl``7776000`Cache TTL in seconds — 90 days (cache driver only)`device_cookie_name``dymo_device_uuid`Cookie name used to identify a device/browser`templates_path``resource_path('labels')`Base directory for `.dymo` template files`sdk_url`DYMO CDNURL to the DYMO JavaScript Framework SDK`auto_load_scripts``false`Auto-include scripts inside the Livewire component`route_prefix``dymo-printer`URL prefix for all package routes`route_middleware``['web']`Middleware applied to all package routes---

State Drivers
-------------

[](#state-drivers)

### Session *(default)*

[](#session-default)

No setup required. Selections are tied to the user's PHP session.

```
DYMO_STATE_DRIVER=session
```

### Cache

[](#cache)

Selections survive session expiry. Good for browser-specific persistence across sessions.

```
DYMO_STATE_DRIVER=cache
```

### Database

[](#database)

Selections are stored in the `dymo_printers` table, keyed by device UUID. Best for multi-device environments where you want a permanent record per device.

```
DYMO_STATE_DRIVER=database
```

Publish and run the migration before using this driver (see Installation step 3).

---

Usage
-----

[](#usage)

### 1. Include the DYMO Scripts

[](#1-include-the-dymo-scripts)

Add the scripts component in your layout, before the closing `` tag:

```

```

Or use the Blade directive shorthand:

```
@dymoscripts
```

To self-host the SDK instead of loading it from DYMO's CDN, set `sdk_url` in your config.

### 2. Printer Selection UI

[](#2-printer-selection-ui)

#### Standalone Alpine.js *(no Livewire required)*

[](#standalone-alpinejs-no-livewire-required)

```

```

The component uses the REST API (`/dymo-printer/printer`) and stores the selection via the configured state driver. It lazy-loads the printer list on first focus.

#### Livewire Component

[](#livewire-component)

```

```

If `auto_load_scripts` is `false` (the default), include scripts manually in your layout:

```

```

Both components dispatch a `dymo-printer-saved` browser event when the user saves their selection.

### 3. Printing Labels

[](#3-printing-labels)

#### Single Label *(from a Livewire component)*

[](#single-label-from-a-livewire-component)

```
use GraystackIT\DymoPrinter\Facades\DymoPrinter;

public function printLabel(): void
{
    $this->dispatch(...DymoPrinter::forPrint(
        templateUrl: DymoPrinter::templateUrl('shipping-label.dymo'),
        data: ['RecipientName' => 'John Doe', 'Address' => '123 Main St'],
    ));
}
```

Convenience method equivalent:

```
DymoPrinter::printViaLivewire($this, DymoPrinter::templateUrl('shipping-label.dymo'), [
    'RecipientName' => 'John Doe',
    'Address'       => '123 Main St',
]);
```

#### Batch Print *(from a Livewire component)*

[](#batch-print-from-a-livewire-component)

```
DymoPrinter::batchViaLivewire($this, DymoPrinter::templateUrl('shipping-label.dymo'), [
    ['RecipientName' => 'John Doe',   'Address' => '123 Main St'],
    ['RecipientName' => 'Jane Smith', 'Address' => '456 Oak Ave'],
]);
```

#### Using a Specific Printer

[](#using-a-specific-printer)

Pass a printer name as the last argument to override the stored selection:

```
DymoPrinter::printViaLivewire($this, $url, $data, printerName: 'DYMO LabelWriter 450');
```

### 4. Label Templates

[](#4-label-templates)

Place `.dymo` template files in `resources/labels/` (or the path set in `templates_path`). Templates are created with the free [DYMO Connect](https://www.dymo.com/support/dymo-connect-for-desktop-download.html) desktop app.

Generate a secure URL to serve a template:

```
DymoPrinter::templateUrl('shipping-label.dymo');
// → https://your-app.test/dymo-printer/templates/shipping-label.dymo
```

The template endpoint is protected against path traversal — only `.dymo` files within the configured `templates_path` are served.

### 5. Programmatic State Management

[](#5-programmatic-state-management)

```
use GraystackIT\DymoPrinter\Facades\DymoPrinter;

DymoPrinter::set('DYMO LabelWriter 450');  // Save printer selection
DymoPrinter::get();                         // Get selected printer (or null)
DymoPrinter::has();                         // true if a printer is selected
DymoPrinter::clear();                       // Remove printer selection
```

All methods accept an optional `$deviceId` parameter to target a specific device explicitly.

### 6. Helper Functions

[](#6-helper-functions)

```
dymo_printer();               // Get the currently selected printer name (or null)
dymo_has_printer();           // Whether a printer has been selected (bool)
dymo_template_url($filename); // Generate the URL for a .dymo template file
```

---

Browser Events
--------------

[](#browser-events)

### Events the Package Listens For

[](#events-the-package-listens-for)

Dispatch these from Livewire or anywhere in your JavaScript to trigger a print:

EventPayloadDescription`dymo:print``{ printer, template, data }`Print a single label`dymo:print-batch``{ printer, template, labels }`Print multiple labels in one batch### Events the Package Dispatches

[](#events-the-package-dispatches)

EventPayloadDescription`dymo:print-success``{ printer, count? }`Fired after a successful print`dymo:print-error``{ error: string }`Fired after a print failure (check DYMO Connect is running)`dymo-printer-saved`—Fired when the user saves their printer selection#### Listening in Alpine.js

[](#listening-in-alpinejs)

```

```

#### Listening in Livewire 3

[](#listening-in-livewire-3)

```
#[On('dymo-printer-saved')]
public function onPrinterSaved(): void
{
    // Refresh any printer-dependent state
}
```

---

Multi-Device Support
--------------------

[](#multi-device-support)

The package identifies devices via a UUID cookie (`dymo_device_uuid` by default). Set this cookie in your frontend once per browser so each device maintains its own printer selection:

```
if (!document.cookie.includes('dymo_device_uuid')) {
    const uuid = crypto.randomUUID();
    document.cookie = `dymo_device_uuid=${uuid}; path=/; max-age=${60 * 60 * 24 * 365}`;
}
```

The `cache` and `database` drivers are recommended for multi-device environments.

---

Publishing Assets
-----------------

[](#publishing-assets)

```
# Configuration file
php artisan vendor:publish --tag=dymo-printer-config

# Blade views (to customise the printer-select component)
php artisan vendor:publish --tag=dymo-printer-views

# JavaScript (to self-host dymo-system.js)
php artisan vendor:publish --tag=dymo-printer-assets

# Database migration
php artisan vendor:publish --tag=dymo-printer-migrations
```

---

Testing
-------

[](#testing)

Install dev dependencies and run the test suite:

```
composer install
./vendor/bin/pest
```

Run a specific test file:

```
./vendor/bin/pest tests/Unit/Drivers/SessionDriverTest.php
```

---

License
-------

[](#license)

MIT

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance61

Regular maintenance activity

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ee65c1290d44c83f1c44c965c311a0150c50b4a8eae9e94635973a8a5d245d55?d=identicon)[bharb](/maintainers/bharb)

---

Top Contributors

[![Parvesh96](https://avatars.githubusercontent.com/u/96613912?v=4)](https://github.com/Parvesh96 "Parvesh96 (2 commits)")[![bharb82](https://avatars.githubusercontent.com/u/159435438?v=4)](https://github.com/bharb82 "bharb82 (1 commits)")

### Embed Badge

![Health badge](/badges/graystackit-laravel-dymo-printer/health.svg)

```
[![Health](https://phpackages.com/badges/graystackit-laravel-dymo-printer/health.svg)](https://phpackages.com/packages/graystackit-laravel-dymo-printer)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
