找不到PHPExcel + mPDF类'Mpdf'

问题描述 投票:1回答:2

创建tcPDF文件后,800 + kB但完全为空/白色我查看了Composer和mPDF。安装在本地计算机上并将“供应商”复制到我的Webspace。

我的文件结构:

/WWW/class/my-own-classes
          /PHPExcel
          /vendor/composer
          /vendor/mpdf/mpdf
    /project1/../../../executing-file.php
    /project2/

我结合了我以前的自动加载器和composer-autoloaderlike跟随。

require_once '../../DomainNameClass.php';
spl_autoload_register(function($class) {
    $path = New DomainName("project","intern");
    if($class == 'PHPExcel') {
        require_once $path->classPath . $class . '.php';
    } 
    elseif ( file_exists( $path->classPath . strtolower($class) . 'Class.php' ) ) {
        require_once $path->classPath . strtolower($class) . 'Class.php';
    }
});

$path = New DomainName("dinelco","intern");
require $path -> classPath . "/vendor/autoload.php";

我的PHPExcel-Helper类:

private function setMPDF() {
        $this->rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
        $this->rendererLibrary = 'mpdf7.0.0';
        $this->rendererLibraryPath = dirname(__FILE__).'/vendor/mpdf/mpdf/src';
    }

如果找不到此文件,PHPExcel中的mPDF.php将抛出异常。从现在开始我没有得到例外,我认为我的道路是正确的。

但是:来自PHPExcel / mPDF.php的测试回应对我来说很好看:“发现:/is/htdocs/something/www/class/vendor/mpdf/mpdf/src/Mpdf.php”

然后:致命错误:第96行的/is/htdocs/something/www/class/PHPExcel/Writer/PDF/mPDF.php中找不到类'Mpdf'

在Github mPDF上我读到了关于版本但是我得到了最后一个稳定的(7.0),它将被称为“new mPDF();”而是“new \ Mpdf \ Mpdf();”但那也没有成功。

现在寻找一些小时..我的错误在哪里?

phpexcel mpdf
2个回答
0
投票

据我所知,你必须使用

$mpdf = new \Mpdf\Mpdf();

代替

$mpdf = new Mpdf();

在我的情况下它工作。


0
投票

我这样工作。

    try {
        $mpdf = new Mpdf();
    } catch (MpdfException $e) {
        return $e->getMessage();
    }
© www.soinside.com 2019 - 2024. All rights reserved.