在Debian 8上的php脚本中安装和集成tcpdf

I have a Debian 8 distribution and am trying to get the tcpdf php library running for generating pdf documents. I notice that it is already installed as a package when searching for it in Synaptic Package Manager. It's version 6.0.093+dfsg-1 and its location is /usr/share/doc/php-tcpdf. I looked around online for instructions and tutorials for using the library in my php scripts but haven't found anything explicit and instructive. Neither do the official sites: https://tcpdf.org/ and https://github.com/tecnickcom/tc-lib-pdf offer any setup, installation, or integration documentation.

I downloaded the TCPDF-master.zip from https://github.com/tecnickcom/TCPDF , pasted it into my /var/www/html/ directory, but when I try running one of the examples, or the index.php file, the browser just gives me the following error:

The localhost page isn’t working localhost is currently unable to handle this request. HTTP ERROR 500

The error.log file at /var/log/apache2 displays:

PHP Fatal error:  Unknown: Failed opening required '/var/www/html/tcpdf/examples/example_001.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0

I received the same errors even after installing PEAR and also when trying to run the fpdf library.

Please instruct me to follow the proper procedure on correctly using this library. Thanks.

First, install composer as described at http://www.bravo-kernel.com/2014/08/how-to-install-composer-on-debian/ . Make it globally available by running the following commands while logged in the terminal as user:

  1. $ cd /usr/src
  2. $ sudo apt-get install curl php5-cli
  3. $ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

If the terminal responds with the following errors:

E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

a system restart might be needed due to a possibility of apt-get (or some GUI frontend to it) being halted while executing, leaving apt in a locked state.

Verify the installation:

$ composer --version

which should output:

Composer version 1.3.0 2016-12-24 00:47:03

or something similar.

Afterwards, navigate to the desired directory within terminal where you want to locally install the composer dependency. For instance: /var/www/html/ which is the web root on Debian. Input the command for installing the tcpdf php library:

composer require tecnickcom/tcpdf

as stated at https://packagist.org/packages/tecnickcom/tcpdf

All should now operate as intended.