Install escpos with test page

This commit is contained in:
Craig Rood 2024-12-27 20:57:56 +00:00
parent 1396c31ca5
commit 8af5455905
5 changed files with 1617 additions and 1127 deletions

View File

@ -9,7 +9,11 @@
"guzzlehttp/guzzle": "^7.2", "guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.0", "laravel/framework": "^10.0",
"laravel/sanctum": "^3.2", "laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8" "laravel/tinker": "^2.8",
"mike42/escpos-php": "^4.0",
"ext-gd": "*",
"ext-imagick": "*"
}, },
"require-dev": { "require-dev": {
"fakerphp/faker": "^1.9.1", "fakerphp/faker": "^1.9.1",

2668
composer.lock generated

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Laravel</title>
<link rel="stylesheet" href="{{ url('/css/bootstrap.min.css') }}">
<script src="{{ url('/js/jquery-3.4.1.slim.min.js') }}"></script>
<script src="{{ url('/js/popper.min.js') }}"></script>
<script src="{{ url('/js/bootstrap.min.js') }}"></script>
</head>
<body>
<body>
<div class="alert alert-success" role="alert">
<h3 class="alert-heading">Congratulations!</h3>
<p>This is the printing page.</p>
</div>
<?php
Debugbar::warning('Print Section');
// Print sample code from https://github.com/mike42/escpos-php
use Mike42\Escpos\PrintConnectors\NetworkPrintConnector;
use Mike42\Escpos\Printer;
use Mike42\Escpos\EscposImage;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
$connector = new NetworkPrintConnector("10.99.10.99", 9100);
$printer = new Printer($connector);
try {
// ... Print stuff
$printer -> text("Starting print job...\n");
$printer -> text(date("h:i:sa")."\n");
$printer -> setJustification(Printer::JUSTIFY_CENTER);
// Image!
//$tux = EscposImage::load(public_path("images/escpos-php.png"), false);
$tux = EscposImage::load(public_path("images/escpos-php.png"));
$printer -> bitImage($tux);
$printer -> text("QR Test\n");
// QR Test - remove at some point.
$testStr = "This is a print test!";
$printer -> qrCode($testStr, Printer::QR_ECLEVEL_L, 8, Printer::QR_MODEL_2);
$printer -> cut();
} finally {
$printer -> close();
}
?>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
</body>
</html>

View File

@ -16,3 +16,7 @@ use Illuminate\Support\Facades\Route;
Route::get('/', function () { Route::get('/', function () {
return view('start'); return view('start');
}); });
Route::get('/print', function () {
return view('print');
});