Сервис приложения
Сервисы/PHP (Drupal 10)

Сервис PHP (Drupal 10)

Среда выполнения PHP для сайтов на Drupal со сборкой из исходного кода и связями с общими файлами, кешем и поисковыми сервисами.

Этот сервис запускает ваш код: его образ собирается из Git-репозитория, а каждая сборка развёртывается в окружение.

В StackMaster

Как PHP (Drupal 10) работает в StackMaster

What Wodby sets up for an application that runs on this service. Check it before adding connection settings to the code.

Linked services

Links to other services reach the application as environment variables. Read them in code; do not hardcode hosts or credentials.

LinkVariables
Database (MariaDB, MySQL or PostgreSQL)DB_HOST, DB_PORT, DB_NAME (also DB_DATABASE), DB_USERNAME, DB_PASSWORD, DB_DRIVER (also DB_CONNECTION)
MailMSMTP_HOST, MSMTP_PORT
OpenTelemetry CollectorOTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_PROTOCOL (http/protobuf), OTEL_EXPORTER_OTLP_HEADERS (the Collector's ingest token), OTEL_PHP_AUTOLOAD_ENABLED (true)

Mail needs no code: PHP's mail() is delivered through the linked mail service. An SMTP library or credentials in the codebase are not required.

A variable is present only while its link exists and the linked service is enabled.

The opentelemetry extension is enabled in the image. To send traces, add the OpenTelemetry PHP SDK, the OTLP exporter and an HTTP client with Composer (open-telemetry/sdk, open-telemetry/exporter-otlp and php-http/guzzle7-adapter), plus auto-instrumentation packages for the framework if wanted; with the link, the SDK configures itself from the variables above. Set OTEL_SERVICE_NAME to name the application in traces. Without the link the SDK stays off.

Generated configuration

On every start the container writes $CONF_DIR/wodby.settings.php (normally /var/www/conf/wodby.settings.php), a $wodby array with the environment's hosts, the files directory and the linked database's connection details. Framework services built on this one extend it and include it for the application. It is outside the codebase and rewritten on start: never edit it or copy its values into the repository. In a plain PHP application, read the variables above.

PHP settings

PHP and PHP-FPM are configured through environment variables on the service, such as PHP_MEMORY_LIMIT, PHP_MAX_EXECUTION_TIME or PHP_FPM_PM_MAX_CHILDREN, not through a php.ini in the repository. A change applies with the next deployment of the service.

Environment

  • WODBY_HOSTS is a JSON array of the environment's hosts; WODBY_PRIMARY_HOST and WODBY_PRIMARY_URL are the canonical ones for links generated outside a request.
  • WODBY_ENV_TYPE tells a development environment from a production-like one.

In a development workspace

  • The code is served from the checkout as it is on disk. PHP checks files for changes on every request, so an edit needs no restart.
  • PHP-FPM handles requests as wodby, the user that owns the checkout, so it reads what the developer can read and the files it writes stay editable over SSH.
  • Dependencies are installed by workspace setup with composer install; /vendor/ is kept out of Git status.
  • A change to variables or linked services still needs a deployment of the environment.

Drupal on Wodby

What Wodby sets up for a Drupal application on this service, in addition to the PHP service it is based on. Check it before changing settings.php, connecting Drupal to a cache or search service, or moving the files and configuration directories. Adding a second copy of this configuration to the codebase is the usual mistake.

What Wodby generates

The Drupal PHP container writes two files on every start, from its environment variables:

  • $CONF_DIR/wodby.settings.php (normally /var/www/conf/wodby.settings.php)
  • $CONF_DIR/wodby.sites.php

They are outside the codebase and are rewritten on each start, so never edit them and never copy their values into the repository. sites/<site>/settings.php includes the first one in a block marked // Generated by Wodby., appended at the end of the file by the build or by workspace setup. Keep that block, and keep it after the project's own settings. With a site directory other than default, sites/sites.php includes the second file, which maps the environment's hosts to that site.

Read the generated file to see exactly what applies to this environment. It holds passwords: quote setting names, not secret values.

What it configures

AreaWhat Wodby setsFrom
Database$databases['default']['default'] host, port, name, user, password, driverDB_*, set by the linked database
Hoststrusted_host_patterns for every host of the environmentWODBY_HOSTS
Proxyreverse_proxy and reverse_proxy_addressesrequest, DRUPAL_REVERSE_PROXY_ADDRESSES
Hash salthash_salt, when the project sets noneDRUPAL_HASH_SALT
Filespublic sites/<site>/files, private $FILES_DIR/private, temporary /tmpFILES_DIR
Config syncconfig_sync_directory under $FILES_DIR/config/, when the project sets noneDRUPAL_FILES_SYNC_SALT
CacheRedis connection and cache backend, under the conditions belowREDIS_*
SearchSearch API Solr server credentialsSOLR_CLOUD_*

The database, file paths and trusted hosts are set by Wodby whatever the project's settings say. The hash salt and the config sync directory are only defaults: a project that keeps configuration in Git sets its own config_sync_directory above the Wodby block, and Wodby leaves it alone.

sites/<site>/files is a link to the files volume ($FILES_DIR/public). Uploaded files live on that volume, not in the codebase and not in the image.

Redis or Valkey cache

The connection and the cache backend are configured by Wodby when all of these hold:

  1. The stack's Redis or Valkey service is enabled and linked to the Drupal PHP service. REDIS_HOST is then set in the container.
  2. The drupal/redis module is in the codebase (composer require drupal/redis) under modules/contrib or modules.
  3. The Drupal PHP service has the environment variable DRUPAL_ENABLE_REDIS_CACHE set to a non-empty value, for example 1.

Then the generated settings point redis.connection at the service with the PhpRedis interface, make Redis the default cache backend and load the module's example.services.yml. Do not add Redis settings to settings.php. What is left for the project is to enable the module (drush en redis) and rebuild caches.

A missing condition is the usual reason "Redis is not used": check REDIS_HOST, the module directory and DRUPAL_ENABLE_REDIS_CACHE before changing anything else.

Solr

With a linked Solr service, Wodby overrides the username and password of one Search API Solr server in configuration: the server whose machine name equals SOLR_CLOUD_SERVER, which is the Solr service's host name in the environment (normally solr). Give the Search API server that machine name, and do not store the password in exported configuration or in settings.php. The rest of the server's configuration, such as its connector, host and collection, belongs to the project's own Drupal configuration.

Changing what is wired

Service connections come from the environment's services and their links, not from code:

  • To add a cache or search service, enable it in the environment's services and make sure it is linked to this service, then deploy.
  • A variable such as DRUPAL_ENABLE_REDIS_CACHE is set on this service in the environment. It reaches the container, and the generated settings, with the next deployment of the service.
  • Code changes (composer require, enabling a module, exported configuration) go through the repository as usual.

In a development workspace

A workspace runs the same image against the live checkout, with the same generated files and the same variables. Differences that matter:

  • Workspace setup appends the include to the checkout's settings.php in a form that is safe to commit: it includes the file only where it exists.
  • The checkout's sites/<site>/files becomes a link to the files volume. Setup refuses when that directory is tracked by Git or not ignored; fix the repository instead of working around it.
  • The generated files are rewritten when the container starts. After enabling a service or changing a variable, deploy the environment and check $CONF_DIR/wodby.settings.php again.
  • drush and composer run from the checkout with the same environment as web requests.

Check the result

Confirm against the running environment, not the code alone:

  • drush status shows the database connection.
  • drush php:eval 'var_export(\Drupal\Core\Site\Settings::get("cache"));' shows the cache backend in use.
  • The Search API server page, or drush search-api:server-list, shows whether Solr is reachable.

Обзор

Технический профиль PHP (Drupal 10)

Здесь перечислены версии, которые можно выбрать для PHP (Drupal 10) в стеке или окружении. Сам сервис публикуется ревизиями, и стек ссылается на конкретную ревизию.

Тип сервиса

Сервис приложения

Версии

8.2, 8.3, 8.4

Основан на

Постоянные тома

Files

Стеки

Стеки, в которые входит PHP (Drupal 10)

PHP (Drupal 10) входит в этот публичный стек. Можно создать приложение из публичного стека как есть или добавить сервис в собственный стек.

CI/CD

Сборка PHP (Drupal 10) из Git-репозитория

Начните с публичного шаблона проекта или подключите собственный репозиторий. В StackMaster CI push в ветку, за которой следит окружение, запускает сборку PHP (Drupal 10), а пайплайн её развёртывает.

Vanilla Drupal

Используйте его как есть или клонируйте в свой Git-аккаунт.

wodby/drupal-vanilla

Git-провайдеры

Репозиторий подключается через интеграцию с его Git-провайдером.

CI-провайдеры

StackMaster CI встроен в платформу: пайплайн описывается в файле .wodby/pipeline.yml в репозитории. Для подключённого репозитория те же шаги может выполнять внешний CI-провайдер с помощью StackMaster CLI.

Реестры контейнеров

Собранные образы по умолчанию попадают в StackMaster Registry или во внешний реестр, подключённый как интеграция.

Переменные окружения из интеграций

Интеграция с переменными один раз сохраняет учётные данные стороннего сервиса. Подключите её к PHP (Drupal 10), и StackMaster передаст их в контейнер как переменные окружения во время работы, а не при сборке образа.

Конфигурация

Конфигурация сервиса PHP (Drupal 10)

Сервис PHP (Drupal 10) объявляет следующее. Если значение можно изменить, его задаёт стек, а каждое окружение может его переопределить.

Тома

Files

Настройки

2 настройки, которые стек или окружение могут изменить.

Расписания cron

1 задача по расписанию. Каждый запуск создаёт задачу с логами.

Действия

3 действия. Действие — это команда, которую вы запускаете из панели управления или которую StackMaster выполняет после развёртывания или обновления стека.

Связи сервиса

Каждая связь — это подключение PHP (Drupal 10) к другому сервису. На какой сервис указывает связь, задаёт стек. На карточках перечислены публичные сервисы, которые подходят для каждой связи.

solr

Сервисы, которые подходят для этой связи

redis

Сервисы, которые подходят для этой связи

sendmail

Сервисы, которые подходят для этой связи