I'm have my own magento 2 module. It's allready uploaded on Gitlab. What i must do to install this module using composer require?

You're on the right track with your test module, you just need to move the repository block from your package's composer.json to the main composer file in your Magento installation.

First, fix your module composer file by removing the repository block.

<module-directory>/composer.json

{
    "name": "illia/module-test",
    "description": "13132",
    "license": "proprietary",
    "authors": [
        {
            "name": "Mage2Gen",
            "email": "info@mage2gen.com"
        }
    ],
    "minimum-stability": "dev",
    "require": {},
    "autoload": {
        "psr-4": {
            "Illia\\Test\\": ""
        },
        "files": [
            "registration.php"
        ]
    }
}

Commit those changes, then add a reference to your repository in

<magento-installation-dir>/composer.json

"repositories": [
        {
        "type": "composer",
        "url": "https://repo.magento.com/"
     },
     {
        "type": "git",
        "url": "https://github.com/arefyevi/test.git"
    }
],

Finally, require your package and install

composer require illia/module-test @dev

This process is the same regardless if you're using Gitlab or Github, you'll just need to update the repository url to point to the correct package.

To be able to install the module using composer, Your module should be available at packagist.org, You can link your git repository there. So, you need to Register, and Submit your package there first.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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