Please help. I want to create print function with Codeigniter 4 using mike42/escpos
But the class not found.
This is error message
This is my Folder directory
This is my Autoload file
This is my controller file
And this is my printer configuration
Help me, please. Thank you !
I want to create POS application with direct print using mike42/escpos
The CapabilityProfile
class' full name is Mike42\Escpos\CapabilityProfile
(namespace + classname in the CapabilityProfile.php
file).
'Escpos' => APPPATH . 'ThirdParty/Mike42/Escpos'
tells the autoloader to look for classes which' full name starts with Escpos
in the ThirdParty/Mike42/Escpos
folder, but there are no classes which' full name starts with Escpos
in that folder, they all start with Mike42\Escpos
. That is why it can't find the class when you try to use Escpos\CapabilityProfile;
.
You need to change the array in your Autoload.php
file to:
$psr4 = [
'App' => APPPATH,
APP_NAMESPACE => APPPATH,
'Config' => APPPATH . 'Config',
'Mike42\Escpos' => APPPATH . 'ThirdParty/Mike42/Escpos',
];
And the use statements in your controller to:
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
use Mike42\Escpos\CapabilityProfile;
use Mike42\Escpos\Printer;