Skip to content

Commit

Permalink
Merge pull request #1370 from laravel/mes/php-site-param
Browse files Browse the repository at this point in the history
Update php and composer commands to allow passing in specific site
  • Loading branch information
mattstauffer authored Feb 19, 2023
2 parents 044bdc1 + 5b75cfe commit 9782d48
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions cli/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -641,19 +641,21 @@ function (ConsoleCommandEvent $event) {
/**
* Proxy commands through to an isolated site's version of PHP.
*/
$app->command('php [command]', function (OutputInterface $output, $command) {
$app->command('php [--site=] [command]', function (OutputInterface $output, $command) {
warning('It looks like you are running `cli/valet.php` directly; please use the `valet` script in the project root instead.');
})->descriptions("Proxy PHP commands with isolated site's PHP executable", [
'command' => "Command to run with isolated site's PHP executable",
'--site' => 'Specify the site to use to get the PHP version (e.g. if the site isn\'t linked as its directory name)',
]);

/**
* Proxy commands through to an isolated site's version of Composer.
*/
$app->command('composer [command]', function (OutputInterface $output, $command) {
$app->command('composer [--site=] [command]', function (OutputInterface $output, $command) {
warning('It looks like you are running `cli/valet.php` directly; please use the `valet` script in the project root instead.');
})->descriptions("Proxy Composer commands with isolated site's PHP executable", [
'command' => "Composer command to run with isolated site's PHP executable",
'--site' => 'Specify the site to use to get the PHP version (e.g. if the site isn\'t linked as its directory name)',
]);

/**
Expand Down
14 changes: 12 additions & 2 deletions valet
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,24 @@ then
# Proxy PHP commands to the "php" executable on the isolated site
elif [[ "$1" = "php" ]]
then
$(php "$DIR/cli/valet.php" which-php) "${@:2}"
if [[ $2 == *"--site="* ]]; then
SITE=${2#*=}
$(php "$DIR/cli/valet.php" which-php $SITE) "${@:3}"
else
$(php "$DIR/cli/valet.php" which-php) "${@:2}"
fi

exit

# Proxy Composer commands with the "php" executable on the isolated site
elif [[ "$1" = "composer" ]]
then
$(php "$DIR/cli/valet.php" which-php) $(which composer) "${@:2}"
if [[ $2 == *"--site="* ]]; then
SITE=${2#*=}
$(php "$DIR/cli/valet.php" which-php $SITE) $(which composer) "${@:3}"
else
$(php "$DIR/cli/valet.php" which-php) $(which composer) "${@:2}"
fi

exit

Expand Down

0 comments on commit 9782d48

Please sign in to comment.