Skip to content

Instantly share code, notes, and snippets.

@gcphost
Created February 16, 2017 17:32
Show Gist options
  • Save gcphost/54fe54c04a5c5dc4de6011fecef93e81 to your computer and use it in GitHub Desktop.
Save gcphost/54fe54c04a5c5dc4de6011fecef93e81 to your computer and use it in GitHub Desktop.
Hack to replace repositories in composer.json
<?php
/*
|--------------------------------------------------------------------------
| Remove Local Repositories
|--------------------------------------------------------------------------
|
| This script will remove local repositories from the composer.json and
| replace them with the github version.
|
*/
$composer = json_decode(file_get_contents('composer.json'), true);
file_put_contents('composer.json.bk', json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
unset($composer['repositories']);
$composer['repositories'][] = [
'type' => 'vcs',
'url' => 'https://github.com/../.git',
];
unlink('composer.lock');
echo 'Saving new composer.json.'.file_put_contents('composer.json', json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment