В StackMaster

Как PHP работает в 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.

Обзор

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

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

Тип сервиса

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

Версии

8.5, 8.4, 8.3, 8.2

Стеки

Стеки, в которые входит PHP

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

CI/CD

Сборка PHP из Git-репозитория

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

Composer boilerplate

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

wodby/php-package-boilerplate

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

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

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

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

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

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

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

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

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

Конфигурация сервиса PHP

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

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

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

sendmail

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

На основе этого сервиса

Сервисы на основе PHP

Эти сервисы каталога наследуют конфигурацию PHP и меняют её часть. Собственный сервис может наследовать его так же.