Add Shopware 6 example (#61)

This commit is contained in:
Cynthia Ebert
2025-12-13 20:06:52 +01:00
committed by GitHub
parent 0cd6ace70a
commit 569b86f260
35 changed files with 12770 additions and 0 deletions

11
shopware6/bin/.htaccess Normal file
View File

@@ -0,0 +1,11 @@
<Files ~ ".*">
# Deny all requests from Apache 2.4+.
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
# Deny all requests from Apache 2.0-2.2.
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>
</Files>

View File

@@ -0,0 +1,112 @@
#!/usr/bin/env bash
unset CDPATH
CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
export PROJECT_ROOT="${PROJECT_ROOT:-"$(dirname "$CWD")"}"
export ENV_FILE=${ENV_FILE:-"${PROJECT_ROOT}/.env"}
export NPM_CONFIG_FUND=false
export NPM_CONFIG_AUDIT=false
export NPM_CONFIG_UPDATE_NOTIFIER=false
# shellcheck source=functions.sh
source "${PROJECT_ROOT}/bin/functions.sh"
curenv=$(declare -p -x)
load_dotenv "$ENV_FILE"
# Restore environment variables set globally
set -o allexport
eval "$curenv"
set +o allexport
set -euo pipefail
export APP_URL
export PROJECT_ROOT
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
if [[ -e "${PROJECT_ROOT}/vendor/shopware/platform" ]]; then
ADMIN_ROOT="${ADMIN_ROOT:-"${PROJECT_ROOT}/vendor/shopware/platform/src/Administration"}"
else
ADMIN_ROOT="${ADMIN_ROOT:-"${PROJECT_ROOT}/vendor/shopware/administration"}"
fi
export ADMIN_ROOT
BIN_TOOL="${CWD}/console"
if [[ ${CI:-""} ]]; then
BIN_TOOL="${CWD}/ci"
if [[ ! -x "$BIN_TOOL" ]]; then
chmod +x "$BIN_TOOL"
fi
fi
# build admin
[[ ${SHOPWARE_SKIP_BUNDLE_DUMP:-""} ]] || "${BIN_TOOL}" bundle:dump
"${BIN_TOOL}" feature:dump || true
if [[ $(command -v jq) ]]; then
OLDPWD=$(pwd)
cd "$PROJECT_ROOT" || exit
basePaths=()
while read -r config; do
srcPath=$(echo "$config" | jq -r '(.basePath + .administration.path)')
basePath=$(echo "$config" | jq -r '.basePath')
# the package.json files are always one upper
path=$(dirname "$srcPath")
name=$(echo "$config" | jq -r '.technicalName' )
skippingEnvVarName="SKIP_$(echo "$name" | sed -e 's/\([a-z]\)/\U\1/g' -e 's/-/_/g')"
if [[ ${!skippingEnvVarName:-""} ]]; then
continue
fi
if [[ -n $srcPath && ! " ${basePaths[*]:-} " =~ " ${basePath} " ]]; then
basePaths+=("$basePath")
fi
if [[ -f "$path/package.json" && ! -d "$path/node_modules" && $name != "administration" ]]; then
echo "=> Installing npm dependencies for ${name}"
(cd "$path" && npm install --omit=dev --no-audit --prefer-offline)
fi
done < <(jq -c '.[]' "var/plugins.json")
for basePath in "${basePaths[@]:-}"; do
if [[ -z $basePath ]]; then
continue
fi
if [[ -r "${basePath}/package.json" ]]; then
echo "=> Installing npm dependencies for ${basePath}"
(cd "${basePath}" && npm ci --omit=dev --no-audit --prefer-offline)
fi
if [[ -r "${basePath}/../package.json" ]]; then
echo "=> Installing npm dependencies for ${basePath}/.."
(cd "${basePath}/.." && npm ci --omit=dev --no-audit --prefer-offline)
fi
done
cd "$OLDPWD" || exit
else
echo "Cannot check extensions for required npm installations as jq is not installed"
fi
(cd "${ADMIN_ROOT}"/Resources/app/administration && npm install --prefer-offline --omit=dev)
# Dump entity schema
if [[ -z "${SHOPWARE_SKIP_ENTITY_SCHEMA_DUMP:-""}" ]] && [[ -f "${ADMIN_ROOT}"/Resources/app/administration/scripts/entitySchemaConverter/entity-schema-converter.ts ]]; then
mkdir -p "${ADMIN_ROOT}"/Resources/app/administration/test/_mocks_
"${BIN_TOOL}" -e prod framework:schema -s 'entity-schema' "${ADMIN_ROOT}"/Resources/app/administration/test/_mocks_/entity-schema.json
(cd "${ADMIN_ROOT}"/Resources/app/administration && npm run convert-entity-schema)
fi
(cd "${ADMIN_ROOT}"/Resources/app/administration && npm run build)
[[ ${SHOPWARE_SKIP_ASSET_COPY:-""} ]] ||"${BIN_TOOL}" assets:install

14
shopware6/bin/build-js.sh Normal file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
BIN_DIR="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
set -euo pipefail
if [[ -e "${BIN_DIR}/build-administration.sh" ]]; then
"${BIN_DIR}/build-administration.sh"
fi
if [[ -e "${BIN_DIR}/build-storefront.sh" ]]; then
"${BIN_DIR}/build-storefront.sh"
fi

View File

@@ -0,0 +1,93 @@
#!/usr/bin/env bash
unset CDPATH
CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
set -euo pipefail
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
export PROJECT_ROOT="${PROJECT_ROOT:-"$(dirname "$CWD")"}"
export NPM_CONFIG_FUND=false
export NPM_CONFIG_AUDIT=false
export NPM_CONFIG_UPDATE_NOTIFIER=false
if [[ -e "${PROJECT_ROOT}/vendor/shopware/platform" ]]; then
STOREFRONT_ROOT="${STOREFRONT_ROOT:-"${PROJECT_ROOT}/vendor/shopware/platform/src/Storefront"}"
else
STOREFRONT_ROOT="${STOREFRONT_ROOT:-"${PROJECT_ROOT}/vendor/shopware/storefront"}"
fi
BIN_TOOL="${CWD}/console"
if [[ ${CI:-""} ]]; then
BIN_TOOL="${CWD}/ci"
if [[ ! -x "$BIN_TOOL" ]]; then
chmod +x "$BIN_TOOL"
fi
fi
# build storefront
[[ ${SHOPWARE_SKIP_BUNDLE_DUMP:-""} ]] || "${BIN_TOOL}" bundle:dump
[[ ${SHOPWARE_SKIP_FEATURE_DUMP:-""} ]] || "${BIN_TOOL}" feature:dump
if [[ $(command -v jq) ]]; then
OLDPWD=$(pwd)
cd "$PROJECT_ROOT" || exit
basePaths=()
while read -r config; do
srcPath=$(echo "$config" | jq -r '(.basePath + .storefront.path)')
basePath=$(echo "$config" | jq -r '.basePath')
# the package.json files are always one upper
path=$(dirname "$srcPath")
name=$(echo "$config" | jq -r '.technicalName' )
skippingEnvVarName="SKIP_$(echo "$name" | sed -e 's/\([a-z]\)/\U\1/g' -e 's/-/_/g')"
if [[ ${!skippingEnvVarName:-""} ]]; then
continue
fi
if [[ -n $srcPath && ! " ${basePaths[*]:-} " =~ " ${basePath} " ]]; then
basePaths+=("$basePath")
fi
if [[ -f "$path/package.json" && ! -d "$path/node_modules" && $name != "storefront" ]]; then
echo "=> Installing npm dependencies for ${name}"
(cd "$path" && npm install --prefer-offline)
fi
done < <(jq -c '.[]' "var/plugins.json")
for basePath in "${basePaths[@]:-}"; do
if [[ -z $basePath ]]; then
continue
fi
if [[ -r "${basePath}/package.json" ]]; then
echo "=> Installing npm dependencies for ${basePath}"
(cd "${basePath}" && npm ci --omit=dev --no-audit --prefer-offline)
fi
if [[ -r "${basePath}/../package.json" ]]; then
echo "=> Installing npm dependencies for ${basePath}/.."
(cd "${basePath}/.." && npm ci --omit=dev --no-audit --prefer-offline)
fi
done
cd "$OLDPWD" || exit
else
echo "Cannot check extensions for required npm installations as jq is not installed"
fi
npm --prefix "${STOREFRONT_ROOT}"/Resources/app/storefront install --prefer-offline --omit=dev
node "${STOREFRONT_ROOT}"/Resources/app/storefront/copy-to-vendor.js
npm --prefix "${STOREFRONT_ROOT}"/Resources/app/storefront run production
[[ ${SHOPWARE_SKIP_ASSET_COPY:-""} ]] ||"${BIN_TOOL}" assets:install
[[ ${SHOPWARE_SKIP_THEME_COMPILE:-""} ]] || "${BIN_TOOL}" theme:compile --active-only
if ! [ "${1:-default}" = "--keep-cache" ]; then
"${BIN_TOOL}" cache:clear
fi

55
shopware6/bin/ci Normal file
View File

@@ -0,0 +1,55 @@
#!/usr/bin/env php
<?php
use Shopware\Core\Framework\Adapter\Kernel\KernelFactory;
use Shopware\Core\Framework\Plugin\KernelPluginLoader\ComposerPluginLoader;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
if (!file_exists(__DIR__ . '/../.env') && !file_exists(__DIR__ . '/../.env.dist') && !file_exists(__DIR__ . '/../.env.local.php')) {
$_SERVER['APP_RUNTIME_OPTIONS']['disable_dotenv'] = true;
}
require_once __DIR__ . '/../vendor/autoload_runtime.php';
return static function (array &$context) {
set_time_limit(0);
$classLoader = require __DIR__ . '/../vendor/autoload.php';
if (!class_exists(Application::class)) {
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
}
if (!isset($context['PROJECT_ROOT'])) {
$context['PROJECT_ROOT'] = dirname(__DIR__);
}
$input = new ArgvInput();
$env = $input->getParameterOption(['--env', '-e'], $context['APP_ENV'] ?? 'prod', true);
$debug = ($context['APP_DEBUG'] ?? ($env !== 'prod')) && !$input->hasParameterOption('--no-debug', true);
if ($input->getFirstArgument() === 'system:install') {
$context['INSTALL'] = true;
}
if (trim($context['DATABASE_URL'] ?? '') === '') {
// fake DATABASE_URL
$_SERVER['DATABASE_URL'] = 'mysql://_placeholder.test';
}
$kernel = KernelFactory::create(
environment: $env,
debug: $debug,
classLoader: $classLoader,
pluginLoader: new ComposerPluginLoader($classLoader, null),
);
$application = new Application($kernel);
$kernel->boot();
$application->setName('Shopware');
$application->setVersion($kernel->getContainer()->getParameter('kernel.shopware_version'));
return $application;
};

66
shopware6/bin/console Normal file
View File

@@ -0,0 +1,66 @@
#!/usr/bin/env php
<?php
use Shopware\Core\Framework\Adapter\Kernel\KernelFactory;
use Shopware\Core\Framework\Plugin\KernelPluginLoader\ComposerPluginLoader;
use Shopware\Core\Framework\Plugin\KernelPluginLoader\DbalKernelPluginLoader;
use Shopware\Core\Framework\Plugin\KernelPluginLoader\StaticKernelPluginLoader;
use Shopware\Core\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
$envFile = __DIR__ . '/../.env';
if (!file_exists(__DIR__ . '/../.env') && !file_exists(__DIR__ . '/../.env.dist') && !file_exists(__DIR__ . '/../.env.local.php')) {
$_SERVER['APP_RUNTIME_OPTIONS']['disable_dotenv'] = true;
}
require_once __DIR__ . '/../vendor/autoload_runtime.php';
return static function (array &$context) {
set_time_limit(0);
$classLoader = require __DIR__ . '/../vendor/autoload.php';
if (!class_exists(Application::class)) {
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
}
if (!isset($context['PROJECT_ROOT'])) {
$context['PROJECT_ROOT'] = dirname(__DIR__);
}
$input = new ArgvInput();
$env = $input->getParameterOption(['--env', '-e'], $context['APP_ENV'] ?? 'prod', true);
$debug = ($context['APP_DEBUG'] ?? ($env !== 'prod')) && !$input->hasParameterOption('--no-debug', true);
$pluginLoader = new StaticKernelPluginLoader($classLoader, null);
if ($input->getFirstArgument() === 'system:install') {
$context['INSTALL'] = true;
}
if (!isset($context['INSTALL'])) {
$useComposerPluginLoader = (bool) ($context['COMPOSER_PLUGIN_LOADER'] ?? false);
if ($useComposerPluginLoader) {
$pluginLoader = new ComposerPluginLoader($classLoader, null);
} elseif (trim($context['DATABASE_URL'] ?? '') !== '') {
$pluginLoader = new DbalKernelPluginLoader($classLoader, null, Kernel::getConnection());
}
}
$kernel = KernelFactory::create(
environment: $env,
debug: $debug,
classLoader: $classLoader,
pluginLoader: $pluginLoader,
);
$application = new Application($kernel);
$kernel->boot();
$application->setName('Shopware');
$application->setVersion($kernel->getContainer()->getParameter('kernel.shopware_version'));
return $application;
};

View File

@@ -0,0 +1,39 @@
#!/usr/bin/env bash
load_dotenv() {
LOAD_DOTENV=${LOAD_DOTENV:-"1"}
if [[ "$LOAD_DOTENV" == "0" ]]; then
return
fi
CURRENT_ENV=${APP_ENV:-"dev"}
env_file="$1"
# If we have an actual .env file load it
if [[ -e "$env_file" ]]; then
# shellcheck source=/dev/null
source "$env_file"
elif [[ -e "$env_file.dist" ]]; then
# shellcheck source=/dev/null
source "$env_file.dist"
fi
# If we have an local env file load it
if [[ -e "$env_file.local" ]]; then
# shellcheck source=/dev/null
source "$env_file.local"
fi
# If we have an env file for the current env load it
if [[ -e "$env_file.$CURRENT_ENV" ]]; then
# shellcheck source=/dev/null
source "$env_file.$CURRENT_ENV"
fi
# If we have an env file for the current env load it'
if [[ -e "$env_file.$CURRENT_ENV.local" ]]; then
# shellcheck source=/dev/null
source "$env_file.$CURRENT_ENV.local"
fi
}

View File

@@ -0,0 +1,78 @@
#!/usr/bin/env bash
CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
export PROJECT_ROOT="${PROJECT_ROOT:-"$(dirname "$CWD")"}"
export ENV_FILE=${ENV_FILE:-"${PROJECT_ROOT}/.env"}
# shellcheck source=functions.sh
source "${PROJECT_ROOT}/bin/functions.sh"
curenv=$(declare -p -x)
load_dotenv "$ENV_FILE"
# Restore environment variables set globally
set -o allexport
eval "$curenv"
set +o allexport
export HOST=${HOST:-"localhost"}
export VITE_HOST
export ADMIN_PORT
export APP_URL
export SHOPWARE_ADMIN_SKIP_SOURCEMAP_GENERATION
export DISABLE_DEVSERVER_OPEN
export DDEV_PRIMARY_URL
if [[ -e "${PROJECT_ROOT}/vendor/shopware/platform" ]]; then
ADMIN_ROOT="${ADMIN_ROOT:-"${PROJECT_ROOT}/vendor/shopware/platform/src/Administration"}"
else
ADMIN_ROOT="${ADMIN_ROOT:-"${PROJECT_ROOT}/vendor/shopware/administration"}"
fi
export ADMIN_ROOT
BIN_TOOL="${CWD}/console"
[[ ${SHOPWARE_SKIP_BUNDLE_DUMP:-""} ]] || "${BIN_TOOL}" bundle:dump
"${BIN_TOOL}" feature:dump || true
if [[ $(command -v jq) ]]; then
OLDPWD=$(pwd)
cd "$PROJECT_ROOT" || exit
jq -c '.[]' "var/plugins.json" | while read -r config; do
srcPath=$(echo "$config" | jq -r '(.basePath + .administration.path)')
# the package.json files are always one upper
path=$(dirname "$srcPath")
name=$(echo "$config" | jq -r '.technicalName' )
skippingEnvVarName="SKIP_$(echo "$name" | sed -e 's/\([a-z]\)/\U\1/g' -e 's/-/_/g')"
if [[ ${!skippingEnvVarName:-""} ]]; then
continue
fi
if [[ -f "$path/package.json" && ! -d "$path/node_modules" && $name != "administration" ]]; then
echo "=> Installing npm dependencies for ${name}"
(cd "$path" && npm install --omit=dev)
fi
done
cd "$OLDPWD" || exit
else
echo "Cannot check extensions for required npm installations as jq is not installed"
fi
(cd "${ADMIN_ROOT}"/Resources/app/administration && npm install --prefer-offline)
# Dump entity schema
if [[ -z "${SHOPWARE_SKIP_ENTITY_SCHEMA_DUMP:-""}" ]] && [[ -f "${ADMIN_ROOT}"/Resources/app/administration/scripts/entitySchemaConverter/entity-schema-converter.ts ]]; then
mkdir -p "${ADMIN_ROOT}"/Resources/app/administration/test/_mocks_
"${BIN_TOOL}" -e prod framework:schema -s 'entity-schema' "${ADMIN_ROOT}"/Resources/app/administration/test/_mocks_/entity-schema.json
(cd "${ADMIN_ROOT}"/Resources/app/administration && npm run convert-entity-schema)
fi
(cd "${ADMIN_ROOT}"/Resources/app/administration && npm run dev)

View File

@@ -0,0 +1,78 @@
#!/usr/bin/env bash
CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
export PROJECT_ROOT="${PROJECT_ROOT:-"$(dirname "$CWD")"}"
export ENV_FILE=${ENV_FILE:-"${PROJECT_ROOT}/.env"}
export NPM_CONFIG_FUND=false
export NPM_CONFIG_AUDIT=false
export NPM_CONFIG_UPDATE_NOTIFIER=false
# shellcheck source=functions.sh
source "${PROJECT_ROOT}/bin/functions.sh"
curenv=$(declare -p -x)
load_dotenv "$ENV_FILE"
# Restore environment variables set globally
set -o allexport
eval "$curenv"
set +o allexport
export APP_URL
export PROXY_URL
export STOREFRONT_ASSETS_PORT
export STOREFRONT_PROXY_PORT
export STOREFRONT_HTTPS_KEY_FILE
export STOREFRONT_HTTPS_CERTIFICATE_FILE
export STOREFRONT_SKIP_SSL_CERT
if [[ -e "${PROJECT_ROOT}/vendor/shopware/platform" ]]; then
STOREFRONT_ROOT="${STOREFRONT_ROOT:-"${PROJECT_ROOT}/vendor/shopware/platform/src/Storefront"}"
else
STOREFRONT_ROOT="${STOREFRONT_ROOT:-"${PROJECT_ROOT}/vendor/shopware/storefront"}"
fi
if [[ ! -d "${STOREFRONT_ROOT}"/Resources/app/storefront/node_modules/webpack-dev-server ]]; then
npm --prefix "${STOREFRONT_ROOT}"/Resources/app/storefront install --prefer-offline
fi
"${CWD}"/console bundle:dump
"${CWD}"/console feature:dump
"${CWD}"/console theme:compile --active-only
if [[ -n "$1" ]]; then
"${CWD}"/console theme:dump --theme-name="$1"
else
"${CWD}"/console theme:dump
fi
if [[ $(command -v jq) ]]; then
OLDPWD=$(pwd)
cd "$PROJECT_ROOT" || exit
jq -c '.[]' "var/plugins.json" | while read -r config; do
srcPath=$(echo "$config" | jq -r '(.basePath + .storefront.path)')
# the package.json files are always one upper
path=$(dirname "$srcPath")
name=$(echo "$config" | jq -r '.technicalName' )
skippingEnvVarName="SKIP_$(echo "$name" | sed -e 's/\([a-z]\)/\U\1/g' -e 's/-/_/g')"
if [[ ${!skippingEnvVarName:-""} ]]; then
continue
fi
if [[ -f "$path/package.json" && ! -d "$path/node_modules" && $name != "storefront" ]]; then
echo "=> Installing npm dependencies for ${name}"
(cd "$path" && npm install)
fi
done
cd "$OLDPWD" || exit
else
echo "Cannot check extensions for required npm installations as jq is not installed"
fi
npm --prefix "${STOREFRONT_ROOT}"/Resources/app/storefront run-script hot-proxy