Skip to content

Commit 4a9fd7c

Browse files
authored
refactor: launch ddev phpmyadmin by port (#14)
1 parent 8123f59 commit 4a9fd7c

3 files changed

Lines changed: 14 additions & 53 deletions

File tree

commands/host/phpmyadmin

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,11 @@
55
## Usage: phpmyadmin
66
## Example: "ddev phpmyadmin"
77

8-
if [ "${DDEV_PROJECT_STATUS-running}" != "running" ] && [ -z "$no_recursion" ]; then
9-
echo "Project ${DDEV_PROJECT} is not running, starting it"
10-
ddev start
11-
start_exit_code=$?
12-
if [ $start_exit_code -ne 0 ]; then
13-
exit $start_exit_code
14-
fi
15-
# run this script again, as the environment is updated after "ddev start"
16-
no_recursion=true ddev "$(basename "$0")" "$@"
17-
exit $?
18-
fi
19-
208
DDEV_PHPMYADMIN_PORT=8036
219
DDEV_PHPMYADMIN_HTTPS_PORT=8037
2210

23-
FULLURL=${DDEV_PRIMARY_URL}
24-
HTTPS=""
25-
if [ ${DDEV_PRIMARY_URL%://*} = "https" ]; then HTTPS=true; fi
26-
27-
if [[ ! -z "${GITPOD_INSTANCE_ID}" ]] || [[ "${CODESPACES}" == "true" ]]; then
28-
FULLURL="${FULLURL/-${DDEV_HOST_WEBSERVER_PORT}/-${DDEV_PHPMYADMIN_PORT}}"
11+
if [ ${DDEV_PRIMARY_URL%://*} = "https" ]; then
12+
ddev launch $DDEV_PRIMARY_URL:$DDEV_PHPMYADMIN_HTTPS_PORT
2913
else
30-
if [ "${HTTPS}" = "" ]; then
31-
FULLURL="${FULLURL%:[0-9]*}:${DDEV_PHPMYADMIN_PORT}"
32-
else
33-
FULLURL="${FULLURL%:[0-9]*}:${DDEV_PHPMYADMIN_HTTPS_PORT}"
34-
fi
35-
fi
36-
37-
if [ -n "${1:-}" ] ; then
38-
if [[ ${1::1} != "/" ]] ; then
39-
FULLURL="${FULLURL}/";
40-
fi
41-
42-
FULLURL="${FULLURL}${1}";
43-
fi
44-
45-
if [ "${DDEV_DEBUG:-}" = "true" ]; then
46-
printf "FULLURL $FULLURL\n" && exit 0
14+
ddev launch $DDEV_PRIMARY_URL:$DDEV_PHPMYADMIN_PORT
4715
fi
48-
49-
case $OSTYPE in
50-
linux-gnu)
51-
if [[ ! -z "${GITPOD_INSTANCE_ID}" ]]; then
52-
gp preview ${FULLURL}
53-
else
54-
xdg-open ${FULLURL}
55-
fi
56-
;;
57-
"darwin"*)
58-
open ${FULLURL}
59-
;;
60-
"win*"* | "msys"*)
61-
start ${FULLURL}
62-
;;
63-
esac
64-

docker-compose.phpmyadmin.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ services:
88
labels:
99
com.ddev.site-name: ${DDEV_SITENAME}
1010
com.ddev.approot: $DDEV_APPROOT
11+
volumes:
12+
- ".:/mnt/ddev_config"
13+
- "ddev-global-cache:/mnt/ddev-global-cache"
1114
expose:
1215
- "80"
1316
environment:

install.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,20 @@ project_files:
77
- docker-compose.phpmyadmin-norouter.yaml
88
- commands/host/phpmyadmin
99

10+
pre_install_actions:
11+
# Ensure we're on DDEV 1.23+. It's need for the `phpmyadmin` command (launch by port).
12+
- |
13+
#ddev-nodisplay
14+
#ddev-description:Checking DDEV version
15+
(ddev debug capabilities | grep corepack >/dev/null) || (echo "Please upgrade DDEV to v1.23+ to use this add-on." && false)
16+
1017
post_install_actions:
1118
- |
1219
#ddev-description:If router disabled, directly expose port
1320
#
1421
if ( {{ contains "ddev-router" (list .DdevGlobalConfig.omit_containers | toString) }} ); then
1522
printf "#ddev-generated\nservices:\n phpmyadmin:\n ports:\n - 8036:80\n" > docker-compose.phpmyadmin-norouter.yaml
1623
fi
17-
- |
24+
- |
1825
echo "You can now use 'ddev phpmyadmin' to launch PhpMyAdmin"
1926

0 commit comments

Comments
 (0)