Repository: ddev/ddev

Issue #2128: Add global --root and --project flags to allow ddev to run in any directory
Created: 2020-03-26T18:58:39Z
Is your feature request related to a problem? Please describe.
Remote ddev server
Describe the solution you'd like
The ability to run ddev commands for a specific project without having to know the path of the project, navigating to the project path and then executing command in that directory.
Currently, I'm using a very complicated jq command to extract the approot of a project name. This requires actually installing jq and proxying the commands via the following script (ddev-proxy):
#!/usr/bin/env bash
# ddev-proxy [PROJECT_NAME] [DDEV COMMAND]
DDEV_PROJECT_NAME=$1 && shift
[[ -z "$DDEV_PROJECT_NAME" ]] && echo "A ddev project name must be the first argument provided" && exit 1
DDEV_PROJECT_APPROOT=$(ddev list -j | jq -r ".raw[] | select(.name | contains(\"$DDEV_PROJECT_NAME\")).approot")
[[ -z "$DDEV_PROJECT_APPROOT" || ! -d "$DDEV_PROJECT_APPROOT/.ddev" ]] && echo "Unable to determine the \"$DDEV_PROJECT_NAME\" ddev directory: $DDEV_PROJECT_APPROOT" && exit 1
cd "$DDEV_PROJECT_APPROOT"
ddev $@
This allows me to setup an alias on my local:
alias rddev='ssh 10.10.1.5 "source ~/.profile && ddev-proxy"'
Then I can simply execute the following on my local:
rddev quo describe

What I would prefer, is to not have to proxy the commands via a custom script at all and instead call ddev directly:
alias rddev='ssh 10.10.1.5 ". ~/.profile && ddev --project "'
Describe alternatives you've considered
Clearly, the above technically works... but it's just more work than is necessary to extract the approot and execute a command for that project. It would be nice if this was just supported natively.
Additional context
None

Duplicate issue #4416: Allow global shell commands/custom commands to be run from everywhere (not just inside a project)
Created: 2022-11-30T14:31:34Z
Is there an existing issue for this?

 I have searched the existing issues

Is your feature request related to a problem?
As it's possible to start a specific project from everywhere on host with :
From my home folder ~/
ddev start projectname
-> projectname starts
Currently, custom commands seems to need to already be in a project folder to run.
If run from outside existing ddev project folder, global commands (from ~/.ddev/commands/host ) are not found :

unknown command "phpstorm" for "ddev"

it could be very useful to run command (ex with "cd" on linux/mac to go to folder) on the specified host project folder from everywhere.
example :
I'm in my home folder ~/
ddev cd projectname
-> open the projectname folder path.
It could be also usefull for existing command  :
I'm in my home folder ~/
ddev phpstorme projectname
-> open the projectname project in phpstorm.
This could be very useful when working with lots of projects rather than manually change folder / open project.
Describe your solution
The first step would be to allow commands to be run from everywhere, even outside from project folders (ex my "home" folder).
The second step would be to find the best way to provide the "project name" parameter to the command, even for existing command like phpstorm.
A bonus step would be that ddev could try to find local commands ([project folder/.ddev/commands) for the specified "project name", that way not all commands need to be "globals".
Describe alternatives
No response
Additional context
No response

Closing comment (2024-04-11T06:19:40Z): This was resolved in #5753
The only outstanding piece is having a flag that lets you run project commands from arbitrary paths, which is essentially just a duplicate of #2128