Platform.sh Deployment

Overview

Platform.sh is a powerful hosting provider for your infrastructure that's quite easy to use.
Keep in mind though, that this is not the only way to go for Apps! You can of course use different services, providers or host everything on a dedicated machine. In this guide, we'd like to let you know what we'd do to get started hosting an App on Platform.sh.
Read more about why this kind of hosting could be useful here or in there official documentation.

Getting started

To deploy your app on Platform.sh, just follow those instructions:

Most important steps

  1. 1.
    Configure your Source Integrations (Optional, but highly recommended!)
  2. 2.
    Install the Platform.sh CLI
  3. 3.
    Authenticate using your Platform.sh account
  4. 4.
    Create required config files. Also, if you create a new project, Platform.sh shows you a checklist where you can generate the code for these files
  5. 5.
    Push your changes to your Git Repo
  6. 6.
    After it's been deployed, migrate the database by connecting via SSH to your project and running the command vendor/bin/doctrine-migrations migrations:migrate
  7. 7.
    That's it!
Your project should now be running at https://console.platform.sh, and you can start developing your own app!

Good to know

Automatic TLS certificates based on Branch / Pull Request

Platform.sh automatically creates a URL and TLS certificate using Let's Encrypt based on your routes.yaml file for every active environment.
You should be aware though that the URL will be built in a specific way. If your branch name gets too long, Let's Encrypt won't be able to generate a certificate.
To avoid this you should configure your Source Integrations to use the name of your Pull Request instead of the Branch Name.

Hook commands

You can place commands like the database migration mentioned above inside your .platform.app.yaml under hooks. This way your commands will be executed every time it deploys a new build (e.g. if your branch gets updated).
Your file could than look like this (with the default AppTemplate):
.platform.app.yaml
hooks:
build: |
set -e
php bin/console assets:install --no-debug
deploy: |
set -e
php bin/console cache:clear
php bin/console doctrine:migrations:migrate --no-interaction
By default, PHP images already run a composer install command, so we don't need that in our hooks. Learn more about that here.

Useful Platform.sh commands

In order to use the following commands you need to have the Platform.sh CLI installed.

List all Platform.sh CLI commands

platform list

Set Platform.sh as new remote host

This step is needed if you want to get more information about the project using the Platform.sh CLI.
platform project:set-remote <Project ID>

Push single branch to Platform.sh and activate it

# Push to Platform.sh
git push -u platform <Branch Name>
# Activate branch
platform environment:activate <Branch Name>

Get available URLs for the current project

platform url

SSH into your project

platform ssh

Connect to the database using SSH tunneling

# List all possible commands
platform tunnel:list
# Open tunnel for all services
platform tunnel:open
# Connect to the remote database normally, as if it were local.
mysql --host=127.0.0.1 --port=30001 --user='user' --password='' --database='main'

Accessing log files

platform log --help
Copy link
Edit on GitHub
On this page
Overview
Getting started
Most important steps
Good to know
Automatic TLS certificates based on Branch / Pull Request
Hook commands
Useful Platform.sh commands
List all Platform.sh CLI commands
Set Platform.sh as new remote host
Push single branch to Platform.sh and activate it
Get available URLs for the current project
SSH into your project
Connect to the database using SSH tunneling
Accessing log files