9

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.

4
  • 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
    Commented Feb 24, 2016 at 9:22
  • i tried this one also but not getting any result Commented Feb 24, 2016 at 9:26
  • Is there a dependency in the main projects composer.json file for your custom module?
    – Smartie
    Commented Feb 24, 2016 at 9:45
  • no but how can we add it in root composer.json Commented Feb 24, 2016 at 9:57

2 Answers 2

8

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.

2
  • I want to use DOMPDF libs without installed via composer . Let me know best way to setup into my extension. Commented Aug 25, 2017 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 Commented Aug 25, 2017 at 6:54
0

Add this :

"module-path": { "type": "path", "url": "app/code/Module/Module" },

to you repository section of the composer json

run composer require module/module

You will install your module and dependencies

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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