Welcome Guest, Not a member yet? Register   Sign In
Trying to use a barcode library with Composer and CI4
#1

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:
...
...
use Dompdf\Dompdf;
use GuzzleHttp\Client;
...
...
$client = new \GuzzleHttp\Client(['http_errors' => false]);
$dompdf = new Dompdf();
...
...

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;
use Picqer\Barcode\BarcodeGeneratorPNG;

But when I try to use it, CodeIgniter does not find it
Code:
$generator = new Picqer\Barcode\BarcodeGeneratorPNG();
Class 'App\Controllers\Picqer\Barcode\BarcodeGeneratorPNG' not found

I've checked the "vendor/composer/autoload_psr4.php" file to see the namespaces.

Any suggestions ?

Thanks a lot
Reply
#2

(This post was last modified: 06-26-2020, 03:36 AM by InsiteFX.)

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(06-26-2020, 03:32 AM)InsiteFX Wrote: its also use Exceptions.
So you would also have to load the Exceptions before the other two classes.

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
Reply
#4

PHP Code:
$generator = new \Picqer\Barcode\BarcodeGeneratorPNG(); 

It miss \
Reply
#5

(06-26-2020, 05:52 AM)Paradinight Wrote:
PHP Code:
$generator = new \Picqer\Barcode\BarcodeGeneratorPNG(); 

It miss \

Wow, it was just that ... It worked!
Thanks @Paradinight
Reply
#6

(06-26-2020, 05:59 AM)kabeza Wrote:
(06-26-2020, 05:52 AM)Paradinight Wrote:
PHP Code:
$generator = new \Picqer\Barcode\BarcodeGeneratorPNG(); 

It miss \

Wow, it was just that ... It worked!
Thanks @Paradinight

If you use "use" you can do:

use Picqer\Barcode\BarcodeGeneratorPNG;

$generator = new BarcodeGeneratorPNG();

or


use Picqer\Barcode\BarcodeGeneratorPNG as AnOtherName;

$generator = new AnOtherName();
Reply
#7

(06-26-2020, 06:19 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();

Great! that worked fine. Thanks again for the useful tips
Reply
#8

If you look at the barcode class files you will see what they are loading.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB