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?
3 Answers
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,

- 201
- 1
- 3
-
2Thanks! I indeed used composer as it "safer" in my opinion. Then I just copy/pasted the mPDF folder where I needed it :-) – LuBre May 18 '18 at 06:52
-
1For anyone else who is a bit overwhelmed by the custom loader shown in the answer, the only part that is actually crucial is the include_once APPPATH.'libraries\vendor\autoload.php'; line. I downloaded the file from the site provided and put the include_once line in my php script, and everything just worked. – JamesHoux Jan 21 '20 at 02:27
-
1As a side note to the person who posted the answer: please post code that follows the minimal example rule. The custom loader convolutes the explanation a lot. – JamesHoux Jan 21 '20 at 02:28
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.

- 6,372
- 2
- 29
- 44
Using MPDF without using composer 1.Open your any htdocs folder and make new file of any extension img-1
- Note: Make sure you installed composer into your local server. if not then check this link composer install
Open that php file into notepad++ file then right click and open folder in cmd. img-2 3. After open cmd, type: “composer require mpdf/mpdf” then enter img-3
After done this, you got 3 files in folder img-4
Make Zip of these 3 files and upload into the server directory with your code
Try with below code
<?php
require_once __DIR__ . '/vendor/autoload.php';
$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML('<h1>Hello world!</h1>');
$mpdf->Output();
?>
For more details :

- 11
- 2