Skip to content

Instantly share code, notes, and snippets.

@GromNaN
Last active July 11, 2019 16:08
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save GromNaN/5536914bc880303dc2ee to your computer and use it in GitHub Desktop.
Split Composer Satis repositories into smaller packages
#!/bin/sh
# For each sub-package, run the Satis build command.
php bin/satis build repositories-mirrors.json ./web/mirrors
php bin/satis build repositories-pear.json ./web/pear
php bin/satis build repositoriesp-rojects.json ./web/projects
# Merge all the package files.
php web/packages.php > web/packages.json
<?php
// File located in web/packages.php
require __DIR__.'/../vendor/autoload.php';
$dirs = array(
'mirrors',
'pear',
'projects',
);
$packages = array(
'packages' => array(),
'includes' => array(),
);
foreach ($dirs as $dir) {
$file = __DIR__.'/'.$dir.'/packages.json';
if (!file_exists($file)) {
fwrite(STDERR, "File $file does not exist.\n");
$packages['includes'][$dir.'/packages.json'] = new stdClass;
continue;
}
$data = json_decode(file_get_contents($file), true);
foreach ($data['includes'] as $key => $value) {
$packages['includes'][$dir.'/'.$key] = $value;
}
}
header('Content-Type: text/plain');
echo Composer\Json\JsonFormatter::format(json_encode($packages), false, true);
echo PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment