Zend Barcode is not rendered? in CodeIgniter

瘦欲@ 提交于 2019-11-28 14:33:58

If you have got it from here https://github.com/desta88/Codeigniter-Barcode-Generator-Zend-Library

1: On the zend library remove CI from CI_Zend

Filename Zend.php

<?php if( ! defined('BASEPATH')) exit('No direct script access allowed');

class Zend { // remove CI_

public function __construct($class = NULL)
{
    ini_set('include_path',
    ini_get('include_path'). PATH_SEPARATOR. APPPATH. 'libraries');

    if($class)
    {
        require_once(string) $class.'.php'; //fixed CI 3 issue by lilsammy
        log_message('debug', "Zend Class $class Loaded");
    }else
    {
        log_message('debug', "Zend Class Initialized");
    }
}

public function load($class)
{
    require_once(string) $class.'.php'; //fixed CI 3 issue by lilsammy
    log_message('debug', "Zend Class $class Loaded");
}

}

Then on the controller should look something like

Filename: Zend_c.php // Just named it like that for testing.

<?php

class Zend_c extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->library('zend');
        $this->zend->load('zend/barcode');
    }

    public function index() {
        $temp = rand(10000, 99999);
        echo $this->set_barcode($temp);
    }

    private function set_barcode($code)
    {
        return Zend_Barcode::render('code128', 'image', array('text'=>$code), array());
    }
}

Working Proof

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!