Skip to main content

๐Ÿ“ฆ Deploying the workshop

Platform.shโ€‹

Platform.sh is a Platform as a Service (PaaS) that allows you to host, build, and scale applications in the cloud. It is a nice tool to deploy and manage your Symfony applications. Before starting make sure you have at least an organisation and one project setup in the Platform.sh UI.

CLI Installation of our projectโ€‹

We will follow the guide on Symfony website to deploy an exsiting project on Platform.sh.

Prerequisitesโ€‹

Authenticate to Platform.sh

platform login

Init the projectโ€‹

In our root directory we will run the following command to initialize the project:

symfony project:init

Setup the project fieldsโ€‹

First we will edit the needed files to deploy

.platform.app.yaml

name: app

type: php:8.2

runtime:
extensions:
- apcu
- mbstring
- sodium
- ctype
- iconv
- mongodb

Add to a local git in order to be able to push the project to Platform.sh

git add .platform.app.yaml .platform/services.yaml .platform/routes.yaml php.ini
git commit -m "Add Platform.sh configuration"

Add secretsโ€‹

platform variable:create --name env:MONGODB_URL --value '<ATLAS_URI>' --sensitive true
platform variable:create --name env:MONGODB_DB --value 'symfony'

Deploy the projectโ€‹

symfony deploy

This will ask for you to select the project and the environment to deploy to. Once its selected the prompt will ask to confirm if you want to push the current git HEAD into the project.

The deployment will take a few minutes to complete. Once it is done, you will be able to access the published URL on the cloud.

Troubleshootingโ€‹

To view the logs you can :

  1. Use the command line
symfony log app --tail
  1. SSH into your cloud pod:
 platform ssh -e  <ENVIRONMENT_NAME> 

app> tail -f /var/log/app.log

๐Ÿ“ฆ Conclusion

In this workshop we have seen how to deploy a Symfony application to the cloud using Platform.sh. We have seen how to create a new project, how to create a new MongoDB database and how to deploy the project to the cloud. We have also seen how to troubleshoot the deployment and how to access the logs of the application.