1

I am developing QrCode Extension in Magento2 which is depended [bacon-qr-code] library so I need to download [bacon-qr-code] library using composer.In Magento2 in root composer.json if I add the

  "require": {
    "magento/module-offline-shipping-sample-data": "100.1.*",
    "bacon/bacon-qr-code": "1.0.1.*"
},

Then it download in vendor folder and I am able to use but what if I provide my Extension to anyone, will he add this line to its main root composer.json file ?? Or download the package manually I am little confuse please suggest me.I followed this link but did not get clear suggestion.

1:- Magento2: How to include third pary module through composer.json in custom module

:-My Module composer.json file

    {
    "name": "Ktpl/Relatedprod",
    "description": "N/A",
    "require": {
        "php": "~5.6.0|7.0.2|~7.0.6",
        "magento/magento-composer-installer": "*",
         "bacon/bacon-qr-code": "1.0.1.*"
    },
    "type": "magento2-module",
    "version": "2.0.0",
    "license": ["GPL-3.0"],
    "autoload": {
        "files": ["registration.php"],
        "psr-4": {
            "Ktpl\\Relatedprod\\": ""
        }
    }
}

enter image description here

5
  • you have to first run command of backon qr code, composer require mpyw/co:^1.5 Commented Oct 14, 2016 at 11:39
  • you have to give recommendation to first install this package using compsoer Commented Oct 14, 2016 at 11:39
  • Where should I add this? in root composer.json or in module composer.json file ? Commented Oct 14, 2016 at 11:54
  • I added my module composer.json file. Commented Oct 14, 2016 at 11:55
  • Is it possible to load libraries using module`s composer.json ?? Commented Oct 14, 2016 at 11:59

1 Answer 1

0

You have to given documentation for this module,

You can set readme.txt file in your module installation.

This is the code for getting Bacon Qr Code in your project.

composer require mpyw/co:^1.5

Just set hint before installation. so after running above command automatically create folder in magento directory.

If you provide extension with composer command to install your module, add require code in composer.json file so when composer update its automatically getting Bacond qr code.

1
  • I added readme.txt file in my module and paste your code [composer require mpyw/co:^1.5 ] in readme.txt file and run composer update command but unable to add the package in the vendor directory. Commented Oct 14, 2016 at 12:44

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.