-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from inpsyde/feat/ddev
Add DDEV Config
- Loading branch information
Showing
32 changed files
with
633 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
WP_STASH_DRIVER=\Stash\Driver\Apc | ||
WP_STASH_DRIVER_ARGS='{"ttl":3600}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
## Description: Set up the development environment | ||
## Usage: orchestrate | ||
## Example: "ddev orchestrate" | ||
|
||
mkdir -p "${DDEV_DOCROOT}" | ||
pushd "${DDEV_DOCROOT}" | ||
PLUGIN_FOLDER="${DDEV_DOCROOT}/wp-content/mu-plugins/${PLUGIN_NAME:-$DDEV_PROJECT}" | ||
VALID_ARGS=$(getopt -o fp: --long force,plugin: -- "$@") | ||
if [[ $? -ne 0 ]]; then | ||
exit 1; | ||
fi | ||
|
||
eval set -- "$VALID_ARGS" | ||
while [ : ]; do | ||
case "$1" in | ||
-f | --force) | ||
echo "Removing WordPress installation" | ||
shift | ||
export RECREATE_ENV=1; | ||
popd | ||
find "${DDEV_DOCROOT}" -mindepth 1 ! -regex "^${PLUGIN_FOLDER}\(/.*\)?" -delete | ||
pushd "${DDEV_DOCROOT}" | ||
;; | ||
--) shift; | ||
break | ||
;; | ||
esac | ||
done | ||
|
||
# Execute all fragments from orchestrate.d | ||
if [ -d "${0}.d" ]; then | ||
for FN in ${0}.d/*.sh ; do | ||
echo $FN | ||
source "${FN}" | ||
done | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
if ! wp core download --version="${WP_VERSION}"; then | ||
echo 'WordPress is already installed.' | ||
exit | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
cat << 'EOF' > ".gitignore" | ||
# Ignores everything in the docroot (docroot in config.yaml); this path may not be included in the standard .ddev/.gitignore. | ||
* | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# Create wp-config.php | ||
# the PHP snippet avoids some notices during CLI calls | ||
# https://make.wordpress.org/cli/handbook/guides/common-issues/#php-notice-undefined-index-on-_server-superglobal | ||
printf ' | ||
if ( defined( "WP_CLI" ) && WP_CLI && ! isset( $_SERVER["HTTP_HOST"] ) ) { | ||
$_SERVER["HTTP_HOST"] = "%s"; | ||
} | ||
' "${DDEV_HOSTNAME}" | wp config create \ | ||
--dbname=db \ | ||
--dbuser=db \ | ||
--dbpass=db \ | ||
--dbhost=db \ | ||
--force \ | ||
--extra-php | ||
|
||
wp config set WP_DEBUG false --raw | ||
wp config set WP_DEBUG_DISPLAY true --raw | ||
wp config set WP_DEBUG_LOG true --raw | ||
wp config set WP_SITEURL '(isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] ? "https://" : "http://") . $_SERVER["HTTP_HOST"]' --raw | ||
wp config set WP_HOME '(isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] ? "https://" : "http://") . $_SERVER["HTTP_HOST"]' --raw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
if [ ! -z "${RECREATE_ENV}" ]; then | ||
echo "Deleting database before creating a new one" | ||
wp db clean --yes --skip-packages | ||
fi | ||
|
||
if [ "${WP_MULTISITE}" = "true" ]; then | ||
wp core multisite-install \ | ||
--title="${WP_TITLE}" \ | ||
--admin_user="${ADMIN_USER}" \ | ||
--admin_password="${ADMIN_PASS}" \ | ||
--url="${DDEV_PRIMARY_URL}" \ | ||
--admin_email="${ADMIN_EMAIL}" \ | ||
--skip-email | ||
|
||
readarray -d , -t slugs <<< "${WP_MULTISITE_SLUGS},"; unset "slugs[-1]"; | ||
for slug in "${slugs[@]}"; do | ||
if [ ! -z "${slug}" ]; then | ||
wp site create --slug="${slug}" | ||
fi | ||
done | ||
|
||
else | ||
wp core install \ | ||
--title="${WP_TITLE}" \ | ||
--admin_user="${ADMIN_USER}" \ | ||
--admin_password="${ADMIN_PASS}" \ | ||
--url="${DDEV_PRIMARY_URL}" \ | ||
--admin_email="${ADMIN_EMAIL}" \ | ||
--skip-email | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
cat << 'EOF' >> ".htaccess" | ||
RewriteEngine On | ||
RewriteBase / | ||
RewriteRule ^index\.php$ - [L] | ||
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] | ||
RewriteCond %{REQUEST_FILENAME} -f [OR] | ||
RewriteCond %{REQUEST_FILENAME} -d | ||
RewriteRule ^ - [L] | ||
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] | ||
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] | ||
RewriteRule . index.php [L] | ||
EOF |
4 changes: 4 additions & 0 deletions
4
.ddev/commands/web/orchestrate.d/20_cleanup_default_plugins.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
wp plugin is-installed akismet && wp plugin uninstall akismet | ||
wp plugin is-installed hello && wp plugin uninstall hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
MU_PLUGIN_LOADER_DIR="wp-content/mu-plugins" | ||
MU_PLUGIN_LOADER_FILE="wp-content/mu-plugins/loader.php" | ||
|
||
mkdir -p "${MU_PLUGIN_LOADER_DIR}" | ||
touch "${MU_PLUGIN_LOADER_FILE}" | ||
|
||
echo "Placing MU Loader at ${MU_PLUGIN_LOADER_FILE}" | ||
|
||
cat << 'EOF' > "${MU_PLUGIN_LOADER_FILE}" | ||
<?php | ||
require_once __DIR__ . '/wp-stash/wp-stash.php'; | ||
EOF |
6 changes: 6 additions & 0 deletions
6
.ddev/commands/web/orchestrate.d/30_install_plugin_packages.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
popd | ||
|
||
composer install | ||
#npm install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
pushd "${DDEV_DOCROOT}" || exit | ||
|
||
flags="--activate" | ||
if [ "${WP_MULTISITE}" = "true" ]; then | ||
flags+=" --network" | ||
fi | ||
|
||
|
||
wp plugin install https://github.com/Rarst/wps/releases/latest/download/wps.zip $flags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
wp rewrite structure '/%postname%' | ||
wp rewrite flush |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
## Description: Run WordPress CLI inside the web container. DDEV core only provides this for the "wordpress" project type for some reason | ||
## Usage: wp [flags] [args] | ||
## Example: "ddev wp core version" or "ddev wp plugin install user-switching --activate" | ||
## ProjectTypes: php | ||
|
||
wp "$@" --path=.ddev/wordpress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: wp-stash | ||
type: php | ||
docroot: .ddev/wordpress | ||
php_version: "8.0" | ||
webserver_type: nginx-fpm | ||
router_http_port: "80" | ||
router_https_port: "443" | ||
xdebug_enabled: true | ||
additional_hostnames: [] | ||
additional_fqdns: [] | ||
database: | ||
type: mariadb | ||
version: "10.4" | ||
nfs_mount_enabled: false | ||
mutagen_enabled: false | ||
use_dns_when_possible: true | ||
composer_version: "2" | ||
nodejs_version: "16" | ||
web_environment: | ||
- WP_VERSION=6.2 | ||
- WP_LOCALE=en_US | ||
- WP_TITLE=Inpsyde WP Stash | ||
- ADMIN_USER=admin | ||
- ADMIN_PASS=admin | ||
- ADMIN_EMAIL=admin@example.com | ||
- PLUGIN_NAME=wp-stash | ||
|
||
hooks: | ||
pre-start: | ||
- exec-host: | | ||
mkdir -p .ddev/wordpress/wp-content/mu-plugins/${DDEV_PROJECT} | ||
mkdir -p .ddev/wordpress/wp-content/plugins/wp-stash-test-plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: '3.6' | ||
services: | ||
web: | ||
volumes: | ||
- source: ../ | ||
target: /var/www/html/.ddev/wordpress/wp-content/mu-plugins/${DDEV_PROJECT} | ||
type: bind | ||
- source: ../wp-stash-test-plugin | ||
target: /var/www/html/.ddev/wordpress/wp-content/plugins/wp-stash-test-plugin | ||
type: bind | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
source /usr/lib/git-core/git-sh-prompt | ||
|
||
# Ignore duplicate commands, ignore commands starting with a space | ||
export HISTCONTROL=erasedups | ||
# Keep the last 5000 entries | ||
export HISTSIZE=5000 | ||
|
||
# Add global and "project root level" Composer executables to the PATH | ||
export PATH="$HOME/.composer/vendor/bin:$PATH" | ||
export PATH="/var/www/html/vendor/bin:$PATH" | ||
|
||
# Append to the history instead of overwriting (good for multiple connections) | ||
shopt -s histappend | ||
|
||
export PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$\[$(tput sgr0)\] " | ||
|
||
export PHP_IDE_CONFIG='serverName=wp-stash.ddev.site' | ||
#export XDEBUG_CONFIG="mode=debug client_host=127.0.0.1 client_port=9003 start_with_request=yes" | ||
|
||
alias ls='ls --group-directories-first' | ||
alias cp='cp -aiv' | ||
alias grep='grep --color=always' | ||
alias tgz='tar -pczf' | ||
|
||
profile(){ | ||
XDEBUG_MODE=profile "$1" | ||
} | ||
|
||
# All files in homeadditions/bashrc.d/*.sh will be | ||
# interpreted as shell script so you can use these to | ||
# customize your bash | ||
if [ -d "${HOME}/bashrc.d" ]; then | ||
for FN in ${HOME}/bashrc.d/*.sh ; do | ||
source "${FN}" | ||
done | ||
fi | ||
|
||
cd "${DDEV_DOCROOT}" | ||
|
||
ngrok-url(){ | ||
curl -s localhost:4040/api/tunnels | jq -r .tunnels[0].public_url | awk -F'^http[s]?://' '{print $2}' | ||
} | ||
|
||
wp-replace(){ | ||
wp search-replace "${1}" "${2}" --network --precise --recurse-objects --verbose | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
.idea/ | ||
/vendor | ||
composer.lock | ||
tmp | ||
tmp |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.