How do I install mpdf 7 without composer?

|▌冷眼眸甩不掉的悲伤 提交于 2020-04-09 20:05:48

问题


I'm currently using mpdf 6.1 and I'd like to switch to 7. But I can't find a way to install it without composer. Is there a full package that I can download, unzip and test on my localhost?


回答1:


well, i've spend few days to search a way, finally i found it, you can download full package mpdf in this site, after download extract files and place on your project and load 'vendor/autoload.php'. in my case i use it with codeigniter, so i make some php file on libraries folder to load it.

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

class M_pdf 
{ 
    function __construct()
    { 
        include_once APPPATH.'libraries\vendor\autoload.php'; 
    } 
    function pdf()
    { 
        $CI = & get_instance(); 
        log_message('Debug', 'mPDF class is loaded.'); 
    } 
    function load($param=[])
    { 
        return new \Mpdf\Mpdf($param); 
    } 
}

after that i use it on my controller file :

$this->load->library('M_pdf');
$mpdf = $this->m_pdf->load([
   'mode' => 'utf-8',
   'format' => 'A4'
]);

$mpdf->WriteHTML("Hello World!");
$mpdf->Output();

but i still recommend to use composer as well,




回答2:


There is no official v 7.x package including dependencies. To install without composer, you need to do two things:

1) Download the library and all dependencies

For version 7.0.3, that will be

  • psr/log,
  • setasign/fpdi (if you need to import other PDF documents),
  • paragonie/random_compat (if you have PHP 5.6),
  • myclabs/deep-copy

2) Ensure all needed classes are loaded

This means both mPDF classes and dependencies classes.

You can do this manually (reload, find the file with missing class, add require call, repeat) or you can use some autoloading library.


Or, just use composer, it will do all this work for you in one composer require mpdf/mpdf command and one require vendor/autoload.php call.



来源:https://stackoverflow.com/questions/50280869/how-do-i-install-mpdf-7-without-composer

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