Platform.sh YAML structure
Back to home
On this page
In addition to the basic functions you should be familiar with, YAML structure is important. Platform.sh accepts a certain structure for YAML configuration files.
When you run the platform project:init
command, three default YAML configuration files are generated in the .platform
folder and at the root of your source code. They contain the minimum default configuration based on your detected local stack.
These YAML files are a good starting point before customization.
.
โโโ .platform
|ย ย โโโ routes.yaml
|ย ย โโโ services.yaml
โโโ .platform.app.yaml
โโโ <source code>
These three YAML files configure the following:
routes.yaml
: this file contains all of your routes definitionservices.yaml
: this file contains the list of your services definition.platform.app.yaml
: this file contains your application definition
Examples
# Complete list of all available properties
# A unique name for the app. Must be lowercase alphanumeric characters.
# Changing the name destroys data associated with the app.
name: "myapp"
# The runtime the application uses.
# Complete list of available runtimes
type: "php:8.2"
...
# The services of the project.
#
# Each service listed will be deployed
# to power your Platform.sh project.
# Full list of available services
mariadb:
# All available versions are: 10.6, 10.5, 10.4, 10.3
type: mariadb:10.6
# The routes of the project.
#
# Each route describes how an incoming URL is going
# to be processed by Platform.sh.
# More information
"https://{default}/":
type: upstream
upstream: "myapp:http"
# A basic redirect definition
# More information
"https://www.{default}":
type: redirect
to: "https://{default}/"
In these files, you can use any of the available YAML tags you need.
Multi-app
In a multiple application context, you can also group all of your app configurations in a global .platform/applications.yaml
file.
This file contains a list of app configurations, such as:
app1:
type: php:8.3
source:
root: app1
app2:
type: nodejs:20
source:
root: app2