php – DOMPDF library constant error

Question:

I installed the dompdf package in laravel4, using composer. However, it is giving the following error when trying to create the object:

Use of undefined constant DOMPDF_TEMP_DIR – assumed 'DOMPDF_TEMP_DIR'

The php being used is 5.3.10, laravel 4.0.10

creation code:

$pdf = new DOMPDF();

dompdf definitions file code:

def("DOMPDF_TEMP_DIR", sys_get_temp_dir());

Even with changing this definition or including by include , the error persists.

Does anyone know the reason for the error or have you experienced this problem?

Answer:

From what I've read in the documentation, you should require the DOMPDF configuration file, before instantiating the object.

require_once '/path/to/vendor/dompdf/dompdf/dompdf_config.inc.php';

I recommend putting it in the /app/start/global.php file

Source: https://github.com/dompdf/dompdf#install-with-composer

Scroll to Top