Search code examples
phpimagezend-frameworkpngbarcode

zend_barcode in MVC


i just want an Action to print a barcode image, but i can´t get this working in MVC, i just do the following:

public function barcodeAction() {
    $this->_helper->layout->disableLayout();
    $this->_helper->viewRenderer->setNoRender();
    Zend_Barcode::render($_GET['barcodeType'], 'image', $_GET, $_GET);
}

but when I call

/barcode?barcodeType=code39&text=ZEND-FRAMEWORK

I just obtain: "The image couldn't be displayed because it has errors" (or something like that, browser-dependant). Thanks!


Solution

  • You're likely getting an error that you can't see due to the Content-Type header that's sent by Zend_Barcode. Make sure you have log_errors turned on and a valid/writeable destination for the log configured. This way you can check the error log for anything that you normally would have read through your browser.

    https://www.php.net/manual/en/errorfunc.configuration.php#ini.log-errors