i used to use my Laravel Project with PhP 5.6 and i’m using barcode Gnerator for my project some where and to do this i use this package .
laravel/laravel barcode_blog
now i upgraded my PhP To 7.4 (note: didn’t upgrade my laravel yet).
everything is working fine just when i search for a spasific barcode i got this error :
ErrorException in BarcodeGenerator.php line 293:
Array and string offset access syntax with curly braces is deprecated (View:.../.../..)
now this is the code :
<tr>
<td width="19%">serial NUM</td>
<td style="width: 1%">:</td>
<td colspan="2">
@if (!empty($INSTANCE))
<?php $generator = new PicqerBarcodeBarcodeGeneratorHTML(); ?>
{!! $generator->getBarcode($INSTANCE->barcode, $generator::TYPE_CODE_128) !!}
@endif
</td>
</tr>
And I know the problem is with $generator = new PicqerBarcodeBarcodeGeneratorHTML(); this line when i delete it my code is working fine but i need it in the code how to use it in php 7.4 i belive it get changed
2
Answers
Update your composer or to be exact, update picqer/php-barcode-generator version and it will work fine. To update composer, just type
‘composer update’ on the terminal within your project files and it should work.
Installing packages via composer installs packages based on your environment (PHP version).
This means that if you upgrade your PHP version you have to update your installed packages as well via
composer update
as mentioned before.But your versions in composer.json might be locked to some specific versions, in which case you will have to change that as well.
Composer update will leave you an error message then.
What I usual do is:
composer update
In your example you should be able to change the
picqer/php-barcode-generator
package to use version2.1
or higher.