![]() |
Trying to use a barcode library with Composer and CI4 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11) +--- Thread: Trying to use a barcode library with Composer and CI4 (/showthread.php?tid=76842) |
Trying to use a barcode library with Composer and CI4 - kabeza - 06-25-2020 Hi I could successfuly install (in a CI4 install in subfolder) the following libraries with Composer: dompdf and guzzlehttp Then, I use both in the Controller, etc. Code: ... But I cannot make the same with the following one: https://github.com/picqer/php-barcode-generator I've installed with this Code: composer require picqer/php-barcode-generator Then I use with Code: use Picqer\Barcode; But when I try to use it, CodeIgniter does not find it Code: $generator = new Picqer\Barcode\BarcodeGeneratorPNG(); I've checked the "vendor/composer/autoload_psr4.php" file to see the namespaces. Any suggestions ? Thanks a lot RE: Trying to use a barcode library with Composer and CI4 - InsiteFX - 06-26-2020 its also use Exceptions. So you would also have to load the Exceptions before the other two classes. It's also using Imagick for drawing the barcodes. RE: Trying to use a barcode library with Composer and CI4 - kabeza - 06-26-2020 (06-26-2020, 03:32 AM)InsiteFX Wrote: its also use Exceptions. Where did you notice/find that? and how do you know that the Exception classes should be load before the others? (06-26-2020, 03:32 AM)InsiteFX Wrote: It's also using Imagick for drawing the barcodes. Yes, I've both with gd correctly setup Thanks again RE: Trying to use a barcode library with Composer and CI4 - Paradinight - 06-26-2020 PHP Code: $generator = new \Picqer\Barcode\BarcodeGeneratorPNG(); It miss \ RE: Trying to use a barcode library with Composer and CI4 - kabeza - 06-26-2020 (06-26-2020, 05:52 AM)Paradinight Wrote: Wow, it was just that ... It worked! Thanks @Paradinight RE: Trying to use a barcode library with Composer and CI4 - Paradinight - 06-26-2020 (06-26-2020, 05:59 AM)kabeza Wrote:(06-26-2020, 05:52 AM)Paradinight Wrote: If you use "use" you can do: use Picqer\Barcode\BarcodeGeneratorPNG; $generator = new BarcodeGeneratorPNG(); or use Picqer\Barcode\BarcodeGeneratorPNG as AnOtherName; $generator = new AnOtherName(); RE: Trying to use a barcode library with Composer and CI4 - kabeza - 06-26-2020 (06-26-2020, 06:19 AM)Paradinight Wrote: If you use "use" you can do: Great! that worked fine. Thanks again for the useful tips RE: Trying to use a barcode library with Composer and CI4 - InsiteFX - 06-27-2020 If you look at the barcode class files you will see what they are loading. |