Вопрос

Here's my controller:

$html = $this->load->view('print_po', $po, TRUE);
$this->load->library('pdf');
$pdf = $this->pdf->load();

Now I've tried and comment each line and the one that shows the error is:

$pdf = $this->pdf->load();

Here's my library class in application/libraries:

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

class pdf {

    function pdf()
    {
        $CI = & get_instance();
        log_message('Debug', 'mPDF class is loaded.');
    }

    function load($param=NULL)
    {
        include_once APPPATH.'/third_party/mpdf/mpdf.php';

        if ($params == NULL)
        {
            $param = '"en-GB-x","A4","","",10,10,10,10,6,3';
        }

        return new mPDF($param);
    }
}

The error comes only after moving the code from one server to another(the error happens on a CentOS server which I bet is case sensitive). My question here would be: what should I modify so codeIgniter loads Exceptions.php normally?

Это было полезно?

Решение

First, remove the forward-slash at the first of /third_party phrase:

include_once APPPATH.'third_party/mpdf/mpdf.php';

CodeIgniter defines APPPATH constant with a trailing slash. Take a look at index.php:

define('APPPATH', $application_folder.'/');

Second, make sure that the file/folder names are as the same as you have wrote. It's better to keep them all lowercase. Here is a related topic.

Update:

The class name should be Capitalized. In this case change the pdf to Pdf:

class Pdf {
 // ...
}

From CI Documentation:

Naming Conventions:

  • File names must be capitalized. For example: Myclass.php
  • Class declarations must be capitalized. For example: class Myclass
  • Class names and file names must match.
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top