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
?
-
@Krishati95Dev yes, but i have an error: The "github.com/arefyevi/test/packages.json" file could not be downloaded (HTTP/1.1 404 Not Found) – Illia Arefyev Feb 25 '17 at 13:20
-
@Krishati95Dev i've created test emty module and uploaded them on github, but my module on GitLab. – Illia Arefyev Feb 25 '17 at 13:21
-
@Krishati95Dev github.com/arefyevi/test – Illia Arefyev Feb 25 '17 at 13:26
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.
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.