Тип сервиса
Сервис PHP (Laravel)
Среда выполнения PHP для приложений на Laravel со сборкой из исходного кода и связями с хранилищем и кешем.
Этот сервис запускает ваш код: его образ собирается из Git-репозитория, а каждая сборка развёртывается в окружение.
На этой странице
Технический профиль
Версии, репозиторий исходного кода и Helm-чарт.
Стеки с этим сервисом
Публичные стеки, в которые входит этот сервис.
Сборка из исходного кода и CI/CD
Шаблоны проектов, Git-провайдеры, CI и реестры контейнеров.
Конфигурация сервиса
Тома, задачи по расписанию, действия и связи с другими сервисами.
В StackMaster
Как PHP (Laravel) работает в StackMaster
Linked services
Links to other services reach the application as environment variables. Read them in code; do not hardcode hosts or credentials.
| Link | Variables |
|---|---|
| Database (MariaDB, MySQL or PostgreSQL) | DB_HOST, DB_PORT, DB_NAME (also DB_DATABASE), DB_USERNAME, DB_PASSWORD, DB_DRIVER (also DB_CONNECTION) |
MSMTP_HOST, MSMTP_PORT | |
| OpenTelemetry Collector | OTEL_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_HOSTSis a JSON array of the environment's hosts;WODBY_PRIMARY_HOSTandWODBY_PRIMARY_URLare the canonical ones for links generated outside a request.WODBY_ENV_TYPEtells 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.
Laravel on Wodby
What Wodby sets up for a Laravel application on this service, in addition to the PHP service it is based on. Check it before committing a .env, hardcoding connection settings or adding a storage link step.
Generated .env
When the container starts and $APP_ROOT/.env (/var/www/html/.env) does not exist, the image writes one from the container's environment variables. An existing .env, for example one committed to the repository, is left as it is and nothing is generated; keep .env out of the repository.
What the generated file contains:
| Entry | Value comes from |
|---|---|
APP_NAME | WODBY_APP_NAME |
APP_ENV | WODBY_ENV_NAME, the name of the environment |
APP_KEY | APP_KEY, generated by Wodby |
APP_URL | WODBY_PRIMARY_URL |
APP_DEBUG | APP_DEBUG, on in development environments and off elsewhere |
DB_CONNECTION, DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD | the same variables, set by the linked database |
LOG_CHANNEL, LOG_LEVEL | the same variables; the log channel defaults to stderr |
CACHE_DRIVER, SESSION_DRIVER, SESSION_LIFETIME, QUEUE_CONNECTION, FILESYSTEM_DRIVER, BROADCAST_DRIVER | the same variables; cache and sessions default to file, the queue to sync |
REDIS_HOST, REDIS_PORT, REDIS_PASSWORD, MEMCACHED_HOST | the same variables |
MAIL_HOST, MAIL_PORT | the same variables; without them, the linked mail service (MSMTP_HOST, MSMTP_PORT) |
MAIL_MAILER, MAIL_USERNAME, MAIL_PASSWORD, MAIL_ENCRYPTION, MAIL_FROM_ADDRESS, MAIL_FROM_NAME | the same variables |
AWS_*, PUSHER_*, MIX_PUSHER_* | the same variables |
A name that is not in this list is not written to .env. To change any value, set the variable on the service and deploy; do not edit the generated file. The file holds secrets: quote names, not values.
Linked services
- Database: the PHP service's
DB_*variables, includingDB_CONNECTIONandDB_DATABASE, which are the names Laravel's database configuration reads. - Storage (required): the files volume described below.
- Redis or Valkey (optional): the link sets
REDIS_HOST,REDIS_PORTandREDIS_PASSWORD, and setsQUEUE_CONNECTIONtoredis, so queued jobs go to the linked service. Cache and sessions stay on files unlessCACHE_DRIVERandSESSION_DRIVERare set on the service. - Mail: the PHP service's
MSMTP_HOSTandMSMTP_PORT. The generated.envuses them asMAIL_HOSTandMAIL_PORT, so Laravel's SMTP mailer sends through the linked mail service unlessMAIL_HOSTandMAIL_PORTare set on the service.
Init action and files
On container start the service runs its init action (WODBY2_SERVICE_INIT_ACTION, here init-laravel):
storage/app/publicandpublic/storageboth become links to$FILES_DIR/publicon the files volume (mounted at/mnt/files, shared with the web server). This replacesphp artisan storage:link; do not run it in the build. The step fails when one of these directories holds anything other than a.gitignore.storageandbootstrap/cacheare made writable by the web user.
Only storage/app/public is on the volume. The rest of storage, such as logs and file-based sessions and cache, is in the container's file system and does not survive a restart.
What the service runs
- On every deployment:
php artisan migrate --force, in a job of the new version, before its pods are replaced. On the first deployment it runs right after the install. If it fails, the deployment stops before the rollout. The previous version keeps serving until the new one is ready, and keeps serving if the deployment fails, so migrations must keep working with the previous version: add columns and tables first, remove or rename them in a later release. After the first deployment only, once migrations have run:php artisan db:seed. - One cron job runs
php artisan schedule:runevery hour, at minute 0, which is the most often a service schedule can run. Tasks scheduled for other minutes do not run from it: schedule them on the hour, or runphp artisan schedule:workas a long-running process. - The optional Laravel Queue service derived from this one runs
php artisan queue:listen.
Do not add migration or queue worker commands to the build or to a start script.
Changing configuration
Set environment variables on this service: the Laravel names in the table above and the PHP_* variables of the PHP service. They reach the container, and a newly generated .env, with the next deployment.
This service has no development workspace.
Check the result
php artisan aboutshows the environment, URL, and the cache, database, queue and session drivers in use.php artisan migrate:statusconfirms the database connection.ls -l storage/app/public public/storageshows both links to the files volume.
Обзор
Технический профиль PHP (Laravel)
Версии
Основан на
Репозиторий исходного кода
Публичный Helm-чарт
Постоянные тома
Стеки
Стеки, в которые входит PHP (Laravel)
CI/CD
Сборка PHP (Laravel) из Git-репозитория
Laravel on Wodby
Используйте его как есть или клонируйте в свой Git-аккаунт.
wodby/laravel-boilerplateCI-провайдеры
StackMaster CI встроен в платформу: пайплайн описывается в файле .wodby/pipeline.yml в репозитории. Для подключённого репозитория те же шаги может выполнять внешний CI-провайдер с помощью StackMaster CLI.
Реестры контейнеров
Собранные образы по умолчанию попадают в StackMaster Registry или во внешний реестр, подключённый как интеграция.
Переменные окружения из интеграций
Интеграция с переменными один раз сохраняет учётные данные стороннего сервиса. Подключите её к PHP (Laravel), и StackMaster передаст их в контейнер как переменные окружения во время работы, а не при сборке образа.
Конфигурация
Конфигурация сервиса PHP (Laravel)
Тома
Расписания cron
Действия
Связи сервиса
Каждая связь — это подключение PHP (Laravel) к другому сервису. На какой сервис указывает связь, задаёт стек. На карточках перечислены публичные сервисы, которые подходят для каждой связи.
db
Сервисы, которые подходят для этой связи
storage
Сервисы, которые подходят для этой связи
redis
Сервисы, которые подходят для этой связи
sendmail
Сервисы, которые подходят для этой связи
otel
Сервисы, которые подходят для этой связи