0

Please help. I want to create print function with Codeigniter 4 using mike42/escpos

But the class not found.

This is error message

Erro message

This is my Folder directory

Folder Directory

This is my Autoload file

Autoload file

This is my controller file

namespace

Controller file

And this is my printer configuration

printer configuration

Help me, please. Thank you !

I want to create POS application with direct print using mike42/escpos

asked Jan 3, 2024 at 8:20
1
  • 1
    You should copy-paste your code instead of posting screenshots Commented Jan 4, 2024 at 10:37

1 Answer 1

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;
answered Jan 3, 2024 at 17:09
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.