2

Newbie using clean Drupal 8 install on a server. Installed module "International Telephone," but got error. Then I read that I needed to also install Composer. When I tried to install Composer, I received the error that there were .info.yml files.

I've spent hours researching without luck...

7
  • 4
    Composer isn't a Drupal module; you cannot install as such.
    – avpaderno
    Commented Apr 26, 2020 at 13:17
  • Can you mention the exact error you got?
    – Juyal Jee
    Commented Apr 26, 2020 at 18:09
  • 1
    composer-8.x-1.4.tar.gz does not contain any .info.yml files. Commented Apr 28, 2020 at 12:03
  • BTW, I noticed that my original post left out the word "no". As in, there are no .info.yml files. Commented Apr 28, 2020 at 15:10
  • 1
    kiamlaluno, your post confuses me. Composer shows up as a module and includes a ...tar.gz file to install. Can you please clarify your comment? Commented Apr 28, 2020 at 15:18

1 Answer 1

6

IMPORTANT EDIT (2020-04-28):

You are trying to install this project: https://www.drupal.org/project/composer

But that is not Composer -- it's a Drush extension for managing Composer.

From the project documentation:

Composer is a PHP package management tool to help manage your project or libraries' dependencies. This project allows use of Composer from Drush.

Installing this module on the server will not allow you to manage your Drupal 8 project using Composer. You need to set up your Drupal 8 project correctly using Composer in the first place, and worry about getting it onto the server later (whether you use the modern DevOps way using git hooks to deploy, the old-school sysadmin way using rsync to deploy, or the stone-age way using SFTP with Filezilla or a similar GUI file transfer utility.)

ORIGINAL ANSWER (2020-04-26):

Welcome to Drupal Answers!

Since you just started from scratch, you won't lose much work if you start from scratch again.

First, install Composer on your local computer: https://getcomposer.org/

Don't try to install Composer on the server. Depending on your hosting, it may be possible to do that, but it is seldom the best way to do things. Composer is a well-known memory hog, and many web hosts will not allow you to run composer install on the server. Even if it is allowed, it's a terrible misuse of RAM and CPU cycles on a production server. Don't do it.

Next, install a new Drupal 8.8 site on your local computer (here called "my-project") using the drupal/recommended-project template:

composer create-project drupal/recommended-project my-project

At this point, I recommend using git init to put your project in version control.

Then use Composer to manage project dependencies such as installing contrib modules:

composer require drupal/phone_international

You can create a .gitignore file to tell git to ignore the core, contrib and vendor directories, which will be recreated afresh whenever you run composer install (from instructions in the composer.json and composer.lock config files). This keeps your git repo and pull requests small by excluding hundreds of thousands of lines of open-source code that are common to all plain-vanilla Drupal 8 (or 9) projects.

Finally, you'll want to set up some method of deploying the code from your local computer to the server. For tips on that, see my other answer:

https://drupal.stackexchange.com/a/292006/80164

Note that you will probably want to see the local Drupal site in a browser before deploying the code to the server. There are many ways to accomplish this.

Personally I like to use Lando to manage my Drupal projects in Docker containers, but other options include Docksal, DDEV, Vagrant/Virtualbox, LAMP (Linux), MAMP (Mac), WAMP (Windows), XAMPP (Linux, Solaris, Windows, and Mac), and others.

There's a lot to learn, and many of your questions will be outside the scope of this forum (which primarily focuses on issues specific to Drupal core and developing custom module and theme code with Drupal APIs). You might get better support for general questions on Drupal Slack.

Assuming that you want to try Lando, you can install it with all its dependencies using the Hyperdrive installer script for Mac or Linux. Then navigate to the my-project directory you created with composer create-project and execute something like this:

lando init --source cwd --recipe drupal8 --webroot web --name my-project

That would set up Docker containers for your appserver and database with a default configuration suitable for a Drupal 8 project. Then you'd just type:

lando start

Then you can view your local site in the browser at http://my-project.lndo.site to finish installing it and configuring it. After this, you can use Lando to manage your project inside the Docker container. Type lando on a line by itself to see what tools are available (including Composer, Drush, Drupal Console, MySQL CLI, log viewer, and tools to import/export database backups.)

Make sure that every time you change the code, you commit it to git and test it locally before deploying it to the server. (Later, you might end up setting up different servers for Dev, Test and Live environments.)

Good luck, and happy Drupaling!

5
  • hotwebmatter, while I really appreciate your response, installing a new Drupal site on my local computer is just not the direction I want to go; I'd be spending another week or so setting up something that I don't intend to use. That is why I went straight to the server solution. Commented Apr 28, 2020 at 15:12
  • @ThomKolton, that's why I suggested Lando. You will not spend a week setting it up. It will manage a lot of the complexity for you. And I predict that you actually will waste a lot more time trying to deal with Composer on the server. This article is from a couple of years ago, but it makes the case for Lando as a quickstart: colorfield.be/blog/drupal-and-docker-the-easy-way-with-lando Commented Apr 28, 2020 at 15:21
  • I updated my answer to make the cause of (and solution to) your problem more plain. Commented Apr 28, 2020 at 15:39
  • 2
    thank you for taking the time to provide such detailed instructions to this newbie. I'm thankful for all the responses I received and see that the Drupal community is really helpful. This gives me the courage to continue on. Commented May 1, 2020 at 18:49
  • You're welcome! Let me know if you try this from scratch with Composer on your local machine and drupal/recommended-project (with or without Lando!) Commented May 1, 2020 at 18:53

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.