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
-
1You should copy-paste your code instead of posting screenshotszoran404– zoran4042024年01月04日 10:37:22 +00:00Commented Jan 4, 2024 at 10:37
1 Answer 1
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;
Comments
Explore related questions
See similar questions with these tags.