I've built a few sites using Drupal 7 and recently Drupal 8.9... in progress. I'm completely new to Composer, though, and it's apparently a big deal now. It's apparently required in order to use the upgrade status module to figure out if my site's ready to go to Drupal 9.
I read that since 8.9, Composer is built in, but when I run composer commands I get "command not found." Various websites say that's because it's not global... followed by instructions to make it global. But from what I've read elsewhere, it shouldn't be used globally. It's supposed to track dependencies per project.
So I'm hunting around my project to see where the composer.phar is and can't find it.
Obviously I've misunderstood something--or several things. Can someone point me to a good "get composer working on an existing 8.9 site" tutorial for someone who's never used it before?
Ubuntu offers to install it after it tells me the command isn't found. But I'm not seeing that install process recommended anywhere in the Drupal-related Composer info pages.
So, where does the composer executable live? In a specific, nonglobal project, where should it live?
Comments
It is not built-in
It is safe to install composer as a global command (i.e. in
/usr/local/bin). It is correct that it should track dependencies per project. It does so with a pair of files:composer.jsonandcomposer.lock, that lives in the project's root directory.To install on most platforms, including Ubuntu:
Source: http://wikihandbooks.com/webmaster/wm_ubuntu.html#instcomposer
As for using it, I recommend a 4 part series by Jaypan. The first installment is: https://www.morpht.com/blog/drupal-and-composer-part-1-understanding-com...
- gisle
Thanks
I'll attempt a global install.
Part of what caused my confusion is statements like these...
From https://www.drupal.org/docs/installing-drupal/add-composer-to-an-existin...
Sure sounds like it's supposed to be there somewhere ready to use.
Edit: well, installing it was simple enough, but using it appeared to have wrecked my dev site... but it's working again now. I'm really having a hard time seeing why Composer is worth the bother. It apparently has quite a learning curve. At some point, using a "manager" is more work than manually managing... and in its current state, Composer appears to be well past that point. But I'll give it some more effort before I give up I guess.
Indeed poorly formulated and not true
What was meant is that the tarball is created with use of drupal/legacy-project template and ready to be used for its code to be managed with Composer. Obviously, Composer needs to be available to you to be used. When not, you need to install it yourself.
Better
Have it all working now, and I'm seeing additional advantages of using it. There seem to still be a lot of edge cases where you have to edit Composer-related files or use special commands to make it happy, which is additional overhead compared to how I've been doing Drupal over the last decade. But it seems to be the way forward, and hopefully it all gets smoother as more people use it.
I appreciate the help, and maybe I can help improve the documentation a bit after I've gotten to know the tool better. The main takeaway is go ahead and install it globally.
... And expect to do a lot of deciphering of various kinds of messages that composer generates!