PHP code example of janisvepris / zpl-builder-php

1. Go to this page and download the library: Download janisvepris/zpl-builder-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

janisvepris / zpl-builder-php example snippets


use Janisvepris\ZplBuilder\Enum\Font;
use Janisvepris\ZplBuilder\ZplBuilder;

$zpl = (string) ZplBuilder::start()
    ->labelHome(30, 30)
    ->changeFont(Font::Zero, 40, 20)
    ->fieldOrigin(50, 50)
    ->fieldData('Hello, ZPL!')
    ->fieldOrigin(50, 120)
    ->barcodeDefaults(3, 3.0, 100)
    ->barcodeCode128('ABC123')
    ->printQuantity(1)
    ->end();

// ^XA^LH30,30^CF0,40,20^FO50,50^FDHello, ZPL!^FS^FO50,120^BY3,3.0,100^BCN,100,Y,N,N,N^FDABC123^FS^PQ1^XZ

ZplBuilder::start()
    ->raw('^MD15')          // media darkness — no native method yet
    ->raw('^PR4,4,4')       // print rate
    ->end();
bash
composer