Skip to content

Instantly share code, notes, and snippets.

@oscherler
Created May 19, 2014 11:53
Show Gist options
  • Save oscherler/6849e3bba7032086b4f1 to your computer and use it in GitHub Desktop.
Save oscherler/6849e3bba7032086b4f1 to your computer and use it in GitHub Desktop.
Sample code trying to show whether Zend Barcode depends on Zend Validator and/or Zend Service Manager.
{
"require": {
"zendframework/zend-barcode": "@stable"
}
}
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Zend\Barcode\Barcode;
$barcodeOptions = array('text' => 'ZEND-FRAMEWORK');
$rendererOptions = array();
$renderer = Barcode::factory(
'code39', 'image', $barcodeOptions, $rendererOptions
)->render();
# PHP Fatal error: Class 'Zend\ServiceManager\AbstractPluginManager' not found
# in /home/olivier/tests/zend-barcode/vendor/zendframework/zend-barcode/Zend/Barcode/ObjectPluginManager.php
# on line 22
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Zend\Barcode\Barcode;
# In order not to require zend-servicemanager, we can instantiate the barcode and renderer
# directly. I called it convoluted in the issue, but it’s not, just different than the
# examples in the docs.
$barcodeOptions = array('text' => 'ZEND-FRAMEWORK');
$barcode = new Zend\Barcode\Object\Code39( $barcodeOptions );
$rendererOptions = array();
$renderer = new Zend\Barcode\Renderer\Image( $rendererOptions );
$renderer->setBarcode( $barcode )->render();
# PHP Fatal error: Class 'Zend\Validator\Barcode' not found
# in /home/olivier/tests/zend-barcode/vendor/zendframework/zend-barcode/Zend/Barcode/Object/AbstractObject.php
# on line 1200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment