Skip to content

Instantly share code, notes, and snippets.

@tomjn
Created October 25, 2013 10:08
Show Gist options
  • Save tomjn/7152443 to your computer and use it in GitHub Desktop.
Save tomjn/7152443 to your computer and use it in GitHub Desktop.
<?php
$io = new \Composer\IO\BufferIO();
try {
$composer = \Composer\Factory::create($io, null, false);
} catch (\InvalidArgumentException $e) {
if ($required) {
$io->write($e->getMessage());
exit(1);
}
} catch (\Composer\Console\JsonValidationException $e) {
$errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
$message = $e->getMessage() . ':' . PHP_EOL . $errors;
throw new \Composer\Console\JsonValidationException($message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment