我正在使用 magento 1.9。我想使用escpos-php 驱动程序将我们的发票打印到 USB 热敏打印机。我将 escpos-php 库保存在我的 magento 安装的根目录中。在 magento 的自定义模块中,我覆盖了呈现时为 A4 pdf 的默认发票,并尝试制作热发票 pdf(纸张尺寸 C7)。该文件存在于/local/Receipt/Pos/Model/Invoice.php
<?php
class Receipt_Pos_Model_Invoice extends Mage_Sales_Model_Order_Pdf_Invoice
{
public function getPdf($invoices = array())
{
// I want to access the libraries from here in this
// function like shown below. where 'vendor' is a directory
// created by myself.
require(Mage::getBaseDir('lib') .'/vendor/mike42/escpos-php/autoload.php'); // this is the autoloader that comes with escpos-php driver.
use Mike42\Escpos\PrintConnectors\FilePrintConnector; // Warning is raised at this line.
use Mike42\Escpos\Printer;
$connector = new FilePrintConnector("/dev/usb/lp0");
$printer = new Printer($connector);
}
}
?>
我现在尝试的是,我想从此文件访问 escpos-php 驱动程序的类/local/Receipt/Pos/Model/Invoice.php
文件。因此,我已将 escpos-php 驱动程序的自动加载程序的绝对路径添加到 Invoice.php 中的代码中,但它会导致如下所示的警告
Warning: include(Mike42\Escpos\PrintConnectors\PrintConnector.php): failed to open stream: No such file or directory in /var/www/html/checkout/Gama_V2/shop/lib/Varien/Autoload.php on line 94
I think the autoloader of Magento is also trying to find the class files of the escpos-php driver and fails to load it. But I don't want the magento autoloader work here because, I have already included the autoloader of escpos-php driver which takes care of loading its files. How can I avoid this warning and proceed to print receipts? Please help me!