I have created an extension for HTML to PSD by using dompdf Library.

I had tried to using composer and it's working fine.

But I need this Library in my custom extension. When any user add extension directly, it will working fine.

Please let me know proper suggestion with some demo code.


If users can install your extension via composer, add dompdf to your require section:

"require" : {
  "dompdf/dompdf": "0.8.0"

This way it is automatically installed together with your extension.

If you want to create a package that users can drop into app/code, you can add the dompdf sources next to your own code and copy its autoloading declarations to your own composer.json:

+-- Your_Extension
    +-- Dompdf
    |   +-- src
    |   +-- lib
    +-- composer.json
    +-- registration.php

Add to your composer.json:

"autoload": {
    "psr-4" : {
        "Dompdf\\" : "Dompdf/src/"
    "classmap" : ["Dompdf/lib/"]
| improve this answer | |
  • How to call Dompdf into my controller Or helper Or model. Because I have tried to not getting how to call DOMPDF class or object into my extension. – Hitesh Vaghasiya Aug 29 '17 at 13:20
  • @HiteshVaghasiya follow the Dompdf documentation. For example: use Dompdf\Dompdf;, then $dompdf = new Dompdf(); – Fabian Schmengler Aug 29 '17 at 13:30
  • Hello Sir , I have tried using all the way as you given but getting Error : Fatal error: Class 'Dompdf\Dompdf' not found in Path. – Hitesh Vaghasiya Aug 31 '17 at 12:00
  • if you developed in app/code, run composer dump-autoload to update the composer autoloader – Fabian Schmengler Aug 31 '17 at 12:13
  • Hello Sir, I have tried But Still not getting a solution, I am getting same Error "Fatal error" after composer dump-autoload. Can you please explain in depth Or Give me Demo. – Hitesh Vaghasiya Sep 11 '17 at 4:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.