Skip to content

Instantly share code, notes, and snippets.

@molotovbliss
Created November 12, 2019 21:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save molotovbliss/3eb18a2b0366d9b9e15647322641816d to your computer and use it in GitHub Desktop.
Save molotovbliss/3eb18a2b0366d9b9e15647322641816d to your computer and use it in GitHub Desktop.
Warden command for xdebug from CLI
#!/usr/bin/env bash
[[ ! ${WARDEN_COMMAND} ]] && >&2 echo -e "\033[31mThis script is not intended to be run directly!" && exit 1
source "${WARDEN_DIR}/utils/env.sh"
WARDEN_ENV_PATH="$(locateEnvPath)" || exit $?
loadEnvConfig "${WARDEN_ENV_PATH}" || exit $?
pushd "${WARDEN_DIR}" >/dev/null
# docker exec -ti <CONTAINER_ID> php -d xdebug.remote_autostart=on -d xdebug.remote_host=host.docker.internal bin/magento
containerid=$(docker ps -qf "name=debug")
#echo $containerid;
if [[ $containerid != "" ]]; then
echo "xDebug executing on container ... ${WARDEN_PARAMS[0]}";
docker exec -ti $containerid php -d xdebug.remote_autostart=on -d xdebug.remote_host=host.docker.internal "${WARDEN_PARAMS[@]}" "$@"
else
echo "A container image named 'debug' was not found.";
fi
Save above file to /usr/local/Cellar/warden/[x.x.x]/commands/clixdebug.cmd (replacing [x.x.x] with version)
Usage:
`warden clixdebug <php-script-file>`
NOTE: full path not needed.
Example how-to execute via warden:
`warden clixdebug bin/magento`
@chapagain
Copy link

chapagain commented Aug 17, 2022

Just an update

Now, there's a command warden debug
when this is run the user is launched into a shell similarly to when warden shell is run, but in this case the shell is opened by default within the php-debug container.

more details: wardenenv/warden#33 (comment)

@molotovbliss
Copy link
Author

@chapagain Thanks for the update! Glad to hear it's included in warden out of box now. Cheers! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment