Php-Font-Lib Must Either Be Installed via Composer or Copied to Lib/Php-Font-Lib

PHP-font-lib must either be installed via composer or copied to lib/php-font-lib

Dompdf moved recently to Github, and we also added Composer support. For this, we removed the reference to the required external library php-font-lib.

Note: If you are using composer to install dompdf (and php-font-lib), you need to put define("DOMPDF_ENABLE_AUTOLOAD", false); in dompdf_config.custom.inc.php. This will then allow composer to autoload php-font-lib which is installed through dompdf's composer.json file. Otherwise, you may still get an error. (See this issue)

If you are not using composer and want to use the latest edition of dompdf with this library: (source)

  • Get the latest dompdf release from Github and extract it into a directory.
  • Download the library release also from Github
  • Create the dompdf/lib/php-font-lib/classes/ directory.
  • In the zip file, take the contents of the src/FontLib/ folder and paste that into your newly created directory.

HOW TO: convert HTML to PDF with PHP/DOMpdf?

Well apparently it's an issue after domPdf has moved to Github. It seems that php-font-lib library doesn't exist. So one solution is to manually download it:

  • Go to https://github.com/PhenX/php-font-lib and download the library.
  • In the zip file, take the contents of the src/FontLib/ folder and paste that into the folder lib/php-font-lib.

or you can check this answer here

DOMPDF Installation

I had to manually install php-font-lib...

Everything OK now.

Dompdf\Dompdf class not found error

It looks like you downloaded the source code, not a packaged release. The source code download does not include all the dependencies (e.g. php-font-lib) necessary to fully use Dompdf so if you want to use the source code you'll need to download these dependencies separately and also reference their autoloaders.

The recommended method of installing Dompdf is via Composer.

First from the command line: composer require dompdf/dompdf.

Then just use Composer's autoloader in your code: require 'vendor/autoload.php';

If you are unable to use Composer the next recommended method is to download the packaged release. The packaged release includes an autoloader and all dependencies. After installing just reference the included autoloader: require_once 'dompdf/autoload.inc.php';.

If you prefer to continue using the source code directly you'll want to download the dependencies and then load each in turn. (this discussion may help).

require_once '/dompdf/lib/html5lib/Parser.php';
require_once '/php-font-lib/src/FontLib/Autoloader.php';
require_once '/php-svg-lib/src/autoload.php';
require_once '/dompdf/src/Autoloader.php';
Dompdf\Autoloader::register();
use Dompdf\Dompdf;

cakephp 2.1.0 Fatal error: Class 'DOMPDF' not found

The correct file to load for setting up dompdf is dompdf_config.inc.php. dompdf does not currently follow the CakePHP File and Classname Conventions. Since you're loading the class directly instead of using a plugin that utilizes dompdf you'll have to be more explicit. Looking at the App::import() documentation in the CakePHP book, something like the following might work:

App::import($type = 'Vendor', 'DOMPDF', true, array(), 'dompdf_config.inc.php', false);

Of course, if you follow the advice in this answer, you should just use require:

require_once(APP . 'Vendor' . DS . 'dompdf' . DS . 'dompdf_config.inc.php');

Finally, I recommend you drop the utf8_decode() call, so long as you're using dompdf 0.6.0. dompdf 0.5.1 didn't handle UTF8 too well, but the latest release handles it just fine, so long as you've followed the advice in the Unicode How-to.

Your layout should thus look more like the following:

require_once(APP . 'Vendor' . DS . 'dompdf' . DS . 'dompdf_config.inc.php');
$dompdf = new DOMPDF();
$dompdf->load_html($content_for_layout);
$dompdf->render();
echo $dompdf->output();

Composer Download Error (openssl)

I fixed the problem by putting the php.ini file in the c:\windows file, it's a messy solution but it works. I can't use MAMP PRO anymore for some reason it keeps crashing, but it works on MAMP and i installed composer.

PHP Warning: PHP Startup: Unable to load dynamic library 'cassandra.so' (tried: /usr/lib/php/20170718/cassandra

The DataStax PHP driver extension is a wrapper around the C/C++ driver and requires installation of all of its dependencies:

  • C/C++ driver

    • libuv 1.x
    • OpenSSL v1.0.x or v1.1.x (depends on how your PHP is built)
  • The GNU Multiple Precision Arithmetic Library

Since you are using the PHP driver with PHP v7.2 you will need to build the extension as their are no pre-built binaries for this version of PHP:

git clone https://github.com/datastax/php-driver.git
cd php-driver/ext
phpize
cd ..
mkdir build
cd build
../ext/configure
make
sudo make install

Note: The development packages of all of dependencies will be required in order to properly build the extension.

Once the driver is installed you will need to edit your php.ini file to enable the extension which can be located by executing php -r "echo php_ini_loaded_file();":

; DataStax PHP Driver for Apache Cassandra
extension=cassandra.so

To ensure the the driver is being properly loaded via CLI you can execute the following:

php -m | grep cassandra

or

php -i | grep -A 10 "^cassandra$"

php -m will print out all the extension/modules that PHP was able to load whereas php -i will display more verbose information about your PHP installation configuration.



Related Topics



Leave a reply



Submit