Reputation: 41
I'm trying to install dompdf using composer, I followed the instructions from Installing DOMPDF with Composer
So far I've
In composer.json
...
"require": {
...
"dompdf/dompdf": "~0.6.1"
},
"autoload": {
....
run composer update
require __DIR__.'/../vendor/autoload.php';
def("DOMPDF_ENABLE_AUTOLOAD", true);
to def("DOMPDF_ENABLE_AUTOLOAD", false);
```
use Dompdf\Adapter\CPDF;
use Dompdf\Dompdf;
use Dompdf\Exception;
require_once "vendor/dompdf/dompdf/dompdf_config.inc.php";
class ArticleController extends BaseController {
...
public function downloadPdf(){
$dompdf = new Dompdf();
$dompdf->loadHtml('hello world');
$dompdf->render();
$dompdf->output();
}
}
so now when I try to download pdf, if gives me error:
exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'Dompdf\Dompdf' not found'
have I missed any setup step or doing something wrong?
Upvotes: 3
Views: 36799
Reputation: 21
Open file config.php
application/config/config.php
Then Change
$config['composer_autoload'] = "FALSE";
To
$config['composer_autoload'] = "vendor/autoload.php";
Upvotes: 1
Reputation: 41
This issue at dompdf github page helped me to solve this error
The latest stable (0.6.1) does not support namespaces and so would not need the use statement in your code. The upcoming release (0.7.0) does include namespace support.
So, I just removed
use Dompdf\Adapter\CPDF;
use Dompdf\Dompdf;
use Dompdf\Exception;
and used new DOMPDF();
instead of new Dompdf();
as with version 0.6.* namespace will not work.
Upvotes: 1
Reputation: 36934
I don't think that you want use the dompdf 0.6 family. In the 0.6 version all the classes are in global space. But since your code is ready to the 0.7, change it to
"dompdf/dompdf": "~0.7"
and run composer update
.
Upvotes: 1