6

I created a custom module, this module depends on thirt party module(tecnickcom/tcpdf), I added this library in my custom module composer.json file

{
"name": "packagename/mymodule",
"description": "N/A",
"require": {
    "php": "~5.5.0|~5.6.0",
    "magento/magento-composer-installer": "*",
    "tecnickcom/tcpdf":"*"
},
"type": "magento2-module",
"version": "2.0.0",
"license": [
    "GPL-3.0"
],
"autoload": {
    "files": [
        "registration.php"
    ],
    "psr-4": {
        "Packagename\\Mymodule\\": ""
    }
}

}

when i run this composer.json file its create vendor folder in my custom module and download "tecnickcom/tcpdf" library, but it should be in root vendor folder. how can i achieve this.

  • You are running composer update in the wrong place. You need to run it from the root magento directory and not from within your module. – Smartie Feb 24 '16 at 9:22
  • i tried this one also but not getting any result – Yogesh Karodiya Feb 24 '16 at 9:26
  • Is there a dependency in the main projects composer.json file for your custom module? – Smartie Feb 24 '16 at 9:45
  • no but how can we add it in root composer.json – Yogesh Karodiya Feb 24 '16 at 9:57
4

You should only run composer install or composer update in the "root project". In your case this is the Magento installation. But since it seems like you did not add your custom module with composer but developing it as part of the root project, its own composer.json has no effect at all.

So, you have to add the requirement on your own. Run this in the Magento root directory:

composer require tecnickcom/tcpdf

Note that if you publish your module and others install it via composer, this step is not necessary anymore.

  • I want to use DOMPDF libs without installed via composer . Let me know best way to setup into my extension. – Hitesh Vaghasiya Aug 25 '17 at 4:52
  • 1
    @HiteshVaghasiya please post a new question for that , but use the search first. I'm pretty sure there's already a question about third party libraries without composer – Fabian Schmengler Aug 25 '17 at 6:54

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.