0

I started a new project and am pretty new to Magento 2. The person gave me access to there personal git repo with there magento that they use fro production. They also gave a dump of the database.

When I look at the .gitignore file its is the same as on the magento git repo. So I dont have a config.php or evn.php or even an auth.json.

When I try to open the magento from the git I get "Autoload error Vendor autoload is not found. Please run 'composer install' under application root directory."

So then I run composer install, is this really what i should be doing? The person who gave me access to the git said i was doing it wrong but how get the files that it needs to run then?

I get some errors on plugins, looking for passwords they don't have. I delete the plugins from the composer lock file. That gets rid of those errors but then it asks me for the login for repo.magento.com. I try using my creds for magento but those get rejected.

What are the proper creds for the repo.magento.com? It asks for username and password but is actually the keys it is looking for?

Am i doing this right or is there a better way?

1
  • Tried to be thorough with my answer. Let me know if that helps at all or you need any more clarification. Kind of a brain dump.
    – sdaugherty
    Commented Jun 29, 2019 at 2:07

1 Answer 1

1

Here is what you want to do to at least get through the setup of the codebase.

1. Create Magento Account

In order to composer install the magento codebase, you need access keys which are generated from a Magento marketplace account. You must create an account on Magento to get to your marketplace profile to generate access keys.

  1. Go here to create an account if you don't already have one: Magento Login
  2. Once logged in, click the "Marketplace" tab on your account: Marketplace
  3. Click the "Access Keys" link below the "My Products" section on your account dashboard
  4. Generate access keys and copy/write them down. They will be used in the next step

2. Add Composer Auth File to Your Project

In the root of your Magento codebase, you will need to add an auth.json file with the following contents, replacing the username and password with the access keys you generated:

{
    "http-basic": {
        "repo.magento.com": {
            "username": "__YOUR_ACCESS_KEY_USERNAME__",
            "password": "__YOUR_ACCESS_KEY_PASSWORD__"
        }
    }
}

Exception: If some of the extensions used in this project were purchased through the Magento marketplace, you have to use the access keys associated with the Marketplace Account those extensions were purchased under. Otherwise you won't have access to those extensions and will continue to get authentication errors.

3. Add Additional Auth Credentials For Third Party Composer Packages

There may be composer packages used in this project for third party modules and they may be behind a protected composer repository the way Magento is. It sounds like this is the case from what you are describing, so the person whom is giving you access will probably need to share their auth.json with you. It should contain additional entries similar to what you see in the above auth.json but with urls and credentials to the other composer repositories used in the project

4. Composer Install Your Project

You should now be able to run the composer install command. If you get any errors about PHP version or certain system constraints, you can instead run composer install --ignore-platform-reqs to have composer ignore platform requirements

5. Config.php and Env.php

Ideally the app/etc/config.php file should be tracked in the git repo as it's a record of which modules are enabled and disabled. The person giving you access should add this file to the git repo.

The app/etc/env.php file is going to contain the encryption key which I believe you are going to need if the person is giving you an already populated database to use.

Technically you don't need either of these files, but I'm not sure what the effect will be if you are being supplied a database. The env.php file contains the encryption key used for passwords and what not, so that may cause issues if you don't use the same encryption key.

Assuming you can't get either file, you might still be fine. You'll just need go through the previous steps, then visit the site you have configured and it should present you with the installation screen for Magento.

Notes On Composer

You should avoid editing or removing the composer.lock file as MUCH as possible. This file is used to lock all of your composer dependencies at the versions specified in the composer.json. It makes it so that every time you run composer install you get the same versions you originally added.

Even when adding/removing composer packages, it's preferred that you run composer require vendor/package or composer remove vendor/package instead of editing the composer.json file directly. The reason for this is that when you require/remove packages, composer automatically adds/removes content from the composer.lock file for you. When you make manual changes to either of these files, they can become out of sync and cause unexpected issues.

1
  • Thank you, it’s public key is username and private keep is password
    – Marcggc
    Commented Jun 29, 2019 at 16:46

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.