• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using a thrid party Class in CI4

#1
Hello toghether,

i want to use a third party class in my project to generate qr codes.
There is an old libary "qrlib" which is not namespaced but it works :-)

So I added the class "QRcode" to the $classmap Array in the app/config/autoload.php

PHP Code:
        $classmap = [
            
'QRcode' => APPPATH .'third_party/qrcode/qrlib.php'
        
]; 

My question now.. how can i use it? If I use it in a Controller like

PHP Code:
QRcode::png('blablabla'

I get the error "QRcode" could not be found. I thought it is autoloaded? Also I tried to load it manually $this->load() but this function does not longer exists in CI4 Smile

I think this is a simpe question because its about how to use the autoload of CI4 but I dind't found any information in the manual.

Best regards,
Niklas
Reply

#2
Hi, you need to use \QRcode\QRcode::png('blablabla'), as you put that folder under that namespace. If I remember it correctly. Or it's just \QRcode::png('blablabla').
Reply

#3
(05-05-2020, 11:29 AM)jreklund Wrote: Hi, you need to use \QRcode\QRcode::png('blablabla'), as you put that folder under that namespace. If I remember it correctly. Or it's just \QRcode::png('blablabla').

it is not working Undecided

I think you are right but the libary i want to use is not compatible. There are many classes in different Files where filename and classname doesn't match. Everything is just thrown together by a file with many "includes".

So maybe I take the time and write a corrent QR Code Libary or I will search for another one out there... It can't be such a big deal to create qr codes -.-
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.