如何在laravel 5.4中使用ecspos-php?
How to use ecspos-php in laravel 5.4?
先谢谢你了,希望你能帮我解决问题,这是我第一次使用框架laravel 5.4 在windows 7操作系统的struk打印和使用epson U220打印机的情况下已在本地连接 USB,但当我尝试访问页面并单击打印按钮时,打印机无法打印页面。
控制器
<?php
namespace App\Http\Controllers;
use App\Pembayaran;
use Illuminate\Http\Request;
use Yajra\DataTables\DataTables;
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\PrintConnectors\NetworkPrintConnector;
class PembayaranController extends Controller
{
public function print(Request $request)
{
try {
$connector = new WindowsPrintConnector("\wind7\usb\epson");
$printer = new Escpos($connector);
$printer -> text("Hello World!\n");
$printer -> cut();
$printer -> close();
} catch(Exception $e) {
echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
}
}
}
路线
<?php
Auth::routes();
Route::get('/', function () {
return redirect()->route('home');
});
Route::get('/home', 'HomeController@index')->name('home');
Route::post('/pembayaran/print', 'PembayaranController@print')->name('pembayaran.print');
Blade
<form action="{{ route('pembayaran.print') }}" method="POST">
<input type="text" name="username" class="form-control">
<input type="hidden" name="_token" class="form-control" value="{!! csrf_token() !!}">
<button type="submit" name="submit" class="btn btn-info">Print</button
</form>
应该将 share name
作为第一个参数传递给 WindowsPrintConnector
,而不是:
例如:
$connector = new WindowsPrintConnector("epson U220");
如果共享名称是 epson U2020
先谢谢你了,希望你能帮我解决问题,这是我第一次使用框架laravel 5.4 在windows 7操作系统的struk打印和使用epson U220打印机的情况下已在本地连接 USB,但当我尝试访问页面并单击打印按钮时,打印机无法打印页面。
控制器
<?php
namespace App\Http\Controllers;
use App\Pembayaran;
use Illuminate\Http\Request;
use Yajra\DataTables\DataTables;
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\PrintConnectors\NetworkPrintConnector;
class PembayaranController extends Controller
{
public function print(Request $request)
{
try {
$connector = new WindowsPrintConnector("\wind7\usb\epson");
$printer = new Escpos($connector);
$printer -> text("Hello World!\n");
$printer -> cut();
$printer -> close();
} catch(Exception $e) {
echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
}
}
}
路线
<?php
Auth::routes();
Route::get('/', function () {
return redirect()->route('home');
});
Route::get('/home', 'HomeController@index')->name('home');
Route::post('/pembayaran/print', 'PembayaranController@print')->name('pembayaran.print');
Blade
<form action="{{ route('pembayaran.print') }}" method="POST">
<input type="text" name="username" class="form-control">
<input type="hidden" name="_token" class="form-control" value="{!! csrf_token() !!}">
<button type="submit" name="submit" class="btn btn-info">Print</button
</form>
应该将 share name
作为第一个参数传递给 WindowsPrintConnector
,而不是:
例如:
$connector = new WindowsPrintConnector("epson U220");
如果共享名称是 epson U2020