source: trunk/client/inc/hpdf5/spipu/html2pdf/doc/install.md@ 347

Last change on this file since 347 was 347, checked in by roby, 3 years ago

Aggiornamento per compatibilità con php7.4

File size: 1.9 KB
Line 
1# How to Install Html2Pdf
2
3[back](./README.md)
4
5## Composer and Packagist
6
7You must use Composer to install Html2Pdf.
8
9If you do not know what is Composer, you are a few years late...
10
11It is used by all the modern PHP applications (Magento2, Drupal, EasyPlatform, Symfony, ...).
12
13You can read all the pages on https://getcomposer.org/doc/
14
15You can find all the available packages on https://packagist.org/
16
17For example, you can find Html2Pdf: https://packagist.org/packages/spipu/html2pdf
18
19You have to commit the `composer.json` and `composer.lock` files, but **never** commit the `vendor` folder.
20
21If you do not understand why, it is because you have not read the Composer documentation...
22
23## Install
24
25You have just to launch the following command on the root folder of your project:
26
27```bash
28composer require spipu/html2pdf
29```
30
31### First Test
32
33Here is a HelloWorld example, that you can put on the root folder of your project.
34
35```php
36require __DIR__.'/vendor/autoload.php';
37
38use Spipu\Html2Pdf\Html2Pdf;
39
40$html2pdf = new Html2Pdf();
41$html2pdf->writeHTML('<h1>HelloWorld</h1>This is my first test');
42$html2pdf->output();
43```
44
45Html2Pdf use the PSR-4 autoloader of Composer. You have just to require it. Never require manually the classes, it will not work at all. You must use the Composer functionnalities.
46
47Then, you have just to use the main class `Spipu\Html2Pdf\Html2Pdf`, with the 2 main methods `writeHTML` and `output`.
48
49### And on production ?
50
51You have **not** to install composer on your production server.
52
53You have to install composer **only** on your dev environement. Composer is a dev tool.
54
55To deliver you app on a server, you have to (on you dev environement) :
56
57 * Git clone the tag/branch that you want to deliver
58 * Launch the command `composer install --no-dev`
59 * Remove the useless files (like the `.git` folder)
60 * Zip all
61
62That's all, you have a beautifull package that can be deliver on a server !
63
64[back](./README.md)
Note: See TracBrowser for help on using the repository browser.