Reputation: 2280
I am stuck in a very annoying error when trying to load dompdf lib via composer.
Fatal error: require_once(): Failed opening required 'dompdf_config.inc.php' (include_path='.:/usr/local/Cellar/php54/5.4.15/lib/php')
I can tell my php configuration is sure loaded DOM extension
Here is the test code
require 'vendor/autoload.php';
require_once("dompdf_config.inc.php");
$html =
'<html><body>'.
'<p>Hello World!</p>'.
'</body></html>';
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("hello_world.pdf");
I installed dompdf via composer:
What am I missing ?
Upvotes: 0
Views: 6709
Reputation: 1286
I had the same problem and I fixed it by removing the dompdf added by composer and downloaded a version that contains autoload.inc.php
and in my code i've added
require_once ('vendor/dompdf/dompdf/autoload.inc.php');
Then to avoid the Failed to load PDF document
error,you have to add ob_end_clean();
like in the code below
ob_end_clean();
// Output the generated PDF to Browser
$dompdf->stream();
Upvotes: 0
Reputation: 79
There are a few things that you need to do before having dompdf be in a usable state when using Composer.
I followed the installation instructions when using Composer found in a pull request:
https://github.com/adrianmacneil/dompdf/commit/8435a0c2f889698c9edc92ca461f78b27df45549
Upvotes: 0
Reputation: 17215
If the default location of your PHP extension(s) and application(s) doesn't match you can set your include path using (for example):
define('INCLUDE_PATH', '/home/username/php');
@ini_set("include_path", INCLUDE_PATH);
If you don't know the location of your PHP extensions check your PHP configuration or ask your hosting company.
If you don't want to change the value of this option then find out where "dompdf_config.inc.php" is located and use its full path when doing require_once.
Upvotes: 0
Reputation: 13535
With the way you have placed your required
statement.
require_once("dompdf_config.inc.php");
the file dompdf_config.inc.php
has to be in the same path as your script.
Upvotes: 2