1

I'm using composer to manage a Drupal 9 instance. I'm brand new to composer and have no idea what i'm doing. That being said, I've successfully set it up and have used it to install modules and an admin theme. I just purchased a theme and realized that I don't know how how to upload it with composer. For modules and the admin theme I installed, I used composer require drupal/name-of-module(or theme) but this theme doesn't have a shortname and isn't on drupal.org (but rather on my local machine after downloading it). How do I go about uploading this theme with composer? I've looked through the composer documentation but can't find anything about this scenario.

1
  • 1
    I'd put it in web/themes/custom and then git add it. Summary: You have a git repo which contains composer.json, composer.lock, custom modules, custom themes and everything else that's not ignored by .gitignore (which foremost ignores vendor and node_modules folders). Then you commit the changes to the tracked files, pull them on your server or CI and there run composer install and npm i etc. Repo stays lightweight and dependencies only get pulled down where needed.
    – leymannx
    Nov 11, 2021 at 21:19

1 Answer 1

2

You might want to have a look at the documentation on drupal.org:

It's a lot to digest, but it goes into quite some detail on how to use composer and git to manage your site.

The gist of it is this:

You use composer to download code (modules, themes, libraries, ...) that is available somewhere on the internet (github, gitlab, npm, your companies private repositories, ...) and manage the dependencies between the different components that you download.

You use git to manage your project, that is to say your composer.json that defines how and where to get external components, but also your custom code, for example custom modules that you write but that you don't make publicly accessible somewhere, but also that theme that you have purchased. Git allows you to do version control for your project, so that you can safely make changes, go back to a known working state if you break something, and create tagged releases for fixed snapshots of your code.

Once you have all set and your site is running on your local machine as you expect it, the next question is how you get that onto a server, so that your site will become publicly available. This is what I would understand as "uploading" (and there are, as usual, multiple possible ways), but I think this is not what you meant.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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