I am working with magento 1.9. I want to use the escpos-php driver to print our invoices to the usb thermal printer. I have kept the escpos-php libraries in the root directory of my magento installation. In a custom module of magento, I have overwritten the default invoices which was A4 pdf when rendered and I tried to make a thermal invoice pdf (paper size C7). This file exists at /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);
}
}
?>
What am I trying now is, I want to access the class files of the escpos-php driver from this /local/Receipt/Pos/Model/Invoice.php file. So I have added the absolute path of the escpos-php driver's autoloader to the code in Invoice.php but it results in a warning like the one below
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!
To make autoload recognize your external library you will have to follow magento file structure.
External Libraries use to be located under /lib/
in your module you may use them as