Try to use Barcode separate from ZF.
I use composer for install
"zendframework/zend-barcode": "2.7.0",
"zendframework/zend-config": "^2.6.0"
By default composer install requirement zend service manger from ZF3 which is not BC with ZF2
After switch to "zendframework/zend-servicemanager": "^2.7.8" error has gone away
<?php
namespace Project;
use \Zend\Barcode\Barcode;
use \Zend\Barcode\Object\Code25interleaved;
class BarcodeGenerator {
protected $config = [];
function __construct($config = null)
{
$arConf = array(
'barcode' => Code25interleaved::class,
'barcodeParams' => [
'text' => $config['text'],
'withBorder' => true,
'barHeight' => 38,
'factor' => 2,
'font' => 5
],
'renderer' => 'image',
'rendererParams' => [
'imageType' => 'png'
],
);
$this->config = new \Zend\Config\Config($arConf);
}
public function draw(){
$barcode = Barcode::factory($this->config);
return $barcode->draw();
}
public function render(){
$barcode = Barcode::factory($this->config);
$barcode->render();
}
}
Deprecated: Zend\ServiceManager\AbstractPluginManager::__construct now expects a Interop\Container\ContainerInterface instance representing the parent container; please update your code in ./vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php on line 85