Skip to content

Instantly share code, notes, and snippets.

@chukShirley
Created August 4, 2016 19:49
Show Gist options
  • Save chukShirley/0627dc1006787c6af91035c730308846 to your computer and use it in GitHub Desktop.
Save chukShirley/0627dc1006787c6af91035c730308846 to your computer and use it in GitHub Desktop.
<?php
call_user_func(function () {
$phpBinary = '/usr/local/zendsvr6/bin/php-cli';
$baseDirectory = getenv('ZS_APPLICATION_BASE_DIR');
$migrationLogFile = getenv('ZS_MIGRATION_LOG_FILE');
//foreach (['migrations:migrate', 'orm:generate-proxies', 'app:clear-cache'] as $operation) {
foreach (['migrations:migrate', 'app:clear-cache'] as $operation) {
$command = sprintf(
'%s %s %s >> %s',
escapeshellarg($phpBinary),
escapeshellarg($baseDirectory . '/cli.php'),
$operation,
escapeshellarg($migrationLogFile)
);
exec($command, $output, $exitCode);
if ($exitCode) {
throw new \UnexpectedValueException(sprintf(
'Error while executing "%s". The program exited with "%s" and following output: %s',
$command,
$exitCode,
$output
));
}
}
});
<?php
call_user_func(function () {
$phpBinary = '/usr/local/zendsvr6/bin/php-cli';
$baseDirectory = getenv('ZS_APPLICATION_BASE_DIR');
$migrationLogFile = getenv('ZS_MIGRATION_LOG_FILE');
var_dump($migrationLogFile);
//foreach (['migrations:migrate', 'orm:generate-proxies', 'app:clear-cache'] as $operation) {
foreach (['migrations:migrate', 'app:clear-cache'] as $operation) {
$command = sprintf(
'%s %s %s >> %s',
escapeshellarg($phpBinary),
escapeshellarg($baseDirectory . '/cli.php'),
$operation,
escapeshellarg($migrationLogFile)
);
exec($command, $output, $exitCode);
if ($exitCode) {
throw new \UnexpectedValueException(sprintf(
'Error while executing "%s". The program exited with "%s" and following output: %s',
$command,
$exitCode,
$output
));
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment