How to Add a GitHub‑Hosted Composer Package to Your Drupal Project
What if the Drupal module you need isn’t on Packagist? Drupak shows how to leverage Composer’s VCS repository support to pull in GitHub‑hosted packages—ideal for custom modules, forks, or non‑published libraries.
First, confirm the GitHub repository includes a valid composer.json with a proper name and dependency settings. Then in your project’s composer.json, add a repository block of type vcs pointing to the GitHub URL. After that, you simply run composer require vendor/package, specifying branches, tags, or commit hashes as needed.
For private GitHub repos, authentication is required. Drupak also recommends best practices: favor stable releases, avoid cluttering composer.json with unused repositories, and document the GitHub dependencies in your project. This approach gives Drupal developers flexibility while maintaining clean, versioned dependency management.
