Sandbox modules don’t have a drupal.org/project/foo URL like full contrib modules, and therefore you can’t use
composer require drupal/foo to add them.
If you have a Drupal 8 site using drupal-composer/drupal-project, here’s what to edit in composer.json – using a sandbox module of mine as an example.
- Within the repositories section
2. In require (or run
composer require with the name you’ve specified)
You can choose any name you like, but drupal-username/module makes sense to me.
Your sandbox module doesn’t need a composer.json file of it’s own.
If composer hangs and you eventually see this error:
The "https://getcomposer.org/versions" file could not be downloaded: failed to open stream: Operation timed out
it could be a problem with IPv6 (for example if you’ve lost your IPv6 address for some reason.)
On MacOS you can turn IPv6 on and off via the command line. This:
…will give you a list of network interfaces (e.g. Ethernet, Wi-Fi, any VPNs)
networksetup -getinfo Wi-Fi
…will list all it’s settings; IP address, MAC and IPv6 status.
networksetup -setv6off Wi-Fi
…will turn IPv6 off. (To turn it back on, you’ll typically want -setv6automatic, though there’s also an option to set it manually.)
In my experience turning it off fixed the problem immediately, and composer worked straight away.
Obviously it’s preferable to fix your IPv6 and turn it back on, but this may be inconvenient if you have to reboot router etc. or beyond your control if there’s a problem with your ISP.
Useful page to test your IPv6 connection: http://ipv6test.google.com/
See also this GitHub issue
Tested with MacOS El Capitan 10.11.5