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.
To deploy your app on Platform.sh, just follow those instructions:
- Configure your Source Integrations (Optional, but highly recommended!)
- Install the Platform.sh CLI
- Authenticate using your Platform.sh account
- 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
- Push your changes to your Git Repo
- 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
- That's it!
Your project should now be running at https://console.platform.sh, and you can start developing your own app!
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.
Read more about this topic here: https://docs.platform.sh/configuration/routes/https.html#lets-encrypt-limits-errors-and-branch-names.
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 creates a new build.
{% code title=".platform.app.yaml" %}
hooks:
build: |
set -e
php vendor/bin/doctrine-migrations migrations:migrate --no-interaction
deploy: |
set -e
php vendor/bin/doctrine-migrations migrations:migrate --no-interaction
{% endcode %}
In order to use the following commands you need to have the Platform.sh CLI installed.
platform list
This step is needed if you want to get more information about the project using the Platform.sh CLI.
Documentation: https://docs.platform.sh/gettingstarted/introduction/own-code/create-project.html
platform project:set-remote <Project ID>
Documentation: https://docs.platform.sh/gettingstarted/developing/dev-environments/create-environment.html
# Push to Platform.sh
git push -u platform <Branch Name>
# Activate branch
platform environment:activate <Branch Name>
Documentation: https://docs.platform.sh/development/access-site.html#visiting-the-site-on-the-web
platform url
Documentation: https://docs.platform.sh/development/ssh.html
platform ssh
Documentation: https://docs.platform.sh/development/local/tethered.html#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'
Documentation: https://docs.platform.sh/development/logs.html
platform log --help