tecnickcom/tc-lib-barcode

If you really want your simple example to be simple, you should echo it

mudmin opened this issue · 3 comments

The simple example
// output the barcode as HTML div (see other output formats in the documentation and examples)
$bobj->getHtmlDiv();

Does not display anything on the screen and var_dumping $bobj does not give noobs any clues.
A simple fix would be to just change it to

// output the barcode as HTML div (see other output formats in the documentation and examples)
echo $bobj->getHtmlDiv();

Then your example would actually do something tangible.

I re-read my comment and I don't want to come off as snarky. This is a BRILLIANT project and it is very much appreciated. I just know the number of times that I went to a project and if the example doesn't work, I bounce to a new project.

[EDIT]: I needed to enable the gd php extension to fix the error below. The error looked like something that would have been specific to this library.

Btw, your example in the example folder didn't work for me either. I got

Fatal error: Uncaught Error: Call to undefined function Com\Tecnick\Barcode\imagecreate() in C:\xampp\htdocs\xxx\vendor\tecnickcom\tc-lib-barcode\src\Type.php:529 Stack trace: #0 C:\xampp\htdocs\xxxr\vendor\tecnickcom\tc-lib-barcode\src\Type.php(481): Com\Tecnick\Barcode\Type->getGd() #1 C:\xampp\htdocs\xxx\vendor\tecnickcom\tc-lib-barcode\example\index.php(101): Com\Tecnick\Barcode\Type->getPngData() #2 {main} thrown in C:\xampp\htdocs\xxx\vendor\tecnickcom\tc-lib-barcode\src\Type.php on line 529

Thank you for reporting this.
I have updated the README.md file and I will tag a new release soon.

I think the GD library is missing, I used this with docker it is working fine when you add the extension
e.g:
`
FROM php:8.2-apache

RUN apt-get update && apt-get install -y
libfreetype6-dev
libjpeg62-turbo-dev
libzip-dev
libpng-dev
unzip
&& docker-php-ext-configure gd --with-freetype --with-jpeg
&& docker-php-ext-install -j$(nproc) gd zip pdo_mysql

RUN a2enmod rewrite

ENV APACHE_DOCUMENT_ROOT /var/www/html/public

COPY . /var/www/html

WORKDIR /var/www/html

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer

ENV COMPOSER_ALLOW_SUPERUSER 1

RUN apt-get update &&
apt-get install -y zip unzip &&
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN composer install --no-interaction --optimize-autoloader --ignore-platform-reqs
RUN composer require "ext-gd:*" --ignore-platform-reqs

EXPOSE 80

ENV NAME World
CMD ["apache2-foreground"]
`