Skip to content

Commit

Permalink
Add proxy for Drush commands (#635)
Browse files Browse the repository at this point in the history
This will ensure that isolated sites use the correct version of php with Drush. User Login (ULI) has been improved with added uri which is known by Valet.
This requires the added command which-uri to output the domain without any protocol.
  • Loading branch information
EHLOVader authored and mischabraam committed Mar 26, 2024
1 parent c9755e7 commit ef1a943
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cli/valet.php
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,13 @@
$app->command('configure', function () {
DriverConfigurator::configure();
})->descriptions('Configure application with know framework settings');

/**
* Which-uri command which outputs the URL of the current site.
*/
$app->command('which-uri', function () {
output(Site::domain(null));
})->descriptions('Displays the URL of the current site');
}

/**
Expand Down
14 changes: 14 additions & 0 deletions valet-plus
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,20 @@ then

exit

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

exit

# Finally, for every other command we will just proxy into the PHP tool
# and let it handle the request. These are commands which can be run
# without sudo and don't require taking over terminals like Ngrok.
Expand Down

0 comments on commit ef1a943

Please sign in to comment.