Get Started - Platform - SH Documentation
Get Started - Platform - SH Documentation
sh Documentation
Get Started
Symfony is a PHP framework that you can use to create web applications. Platform.sh is the
official Symfony PaaS.
This guide provides instructions for deploying, and working with, Symfony on Platform.sh.
You need:
Git. Git is the primary tool to manage everything your app needs to run. Push commits to
deploy changes and control configuration through YAML files. These files describe your
infrastructure, making it transparent and version-controlled.
A Platform.sh account. If you don’t already have one, register for a trial account. You can sign
up with an email address or an existing GitHub, Bitbucket, or Google account. If you choose
one of these accounts, you can set a password for your Platform.sh account later.
The Symfony CLI. This lets you interact with your project from the command line. You can
also do most things through the Web Console, but this guide focuses on using the CLI.
Note
The Symfony CLI wraps the Platform.sh CLI with added features related to Symfony. So
when using Symfony, you can replace platform <command> by symfony cloud:<command> in
all of your commands.
https://docs.platform.sh/guides/symfony/get-started.html 1/9
27/9/23, 23:38 Get Started | Platform.sh Documentation
To get familiar with Platform.sh, create a new Symfony project from scratch. The present tutorial
uses the Symfony Demo app as an example :
Note
Alternatively, you can deploy an existing Symfony project. To do so, follow these steps:
symfony project:init
Platform.sh manages the entire infrastructure of your project, from code to services (such as
databases, queues, or search engines), all the way to email sending, cron jobs, and workers. This
https://docs.platform.sh/guides/symfony/get-started.html 2/9
27/9/23, 23:38 Get Started | Platform.sh Documentation
To create the project on Platform.sh, run the following command from within the project’s
directory:
The --set-remote flag sets the new project as the remote for this repository.
Tip
You can link any repository to an existing Platform.sh project using the following command:
symfony cloud:deploy
Tip
https://docs.platform.sh/guides/symfony/get-started.html 3/9
27/9/23, 23:38 Get Started | Platform.sh Documentation
During deployment, the logs from the Platform.sh API are displayed in your terminal so you
can monitor progress. To stop the display of the logs without interrupting the deployment,
use CTRL+C in your terminal. To go back to displaying the logs, run symfony
cloud:activity:log .
Now that your app is deployed in production mode, you can define a custom domain for your live
website. To do so, see how to set up a custom domain on Platform.sh, or run the following
command:
Now that your project is deployed, you can start making changes to it. For example, you might
want to fix a bug or add a new feature.
In your project, the main branch always represents the production environment. Other branches
are for developing new features, fixing bugs, or updating the infrastructure.
1. Create a new environment (a Git branch) to make changes without impacting production:
This command creates a new local feat-a Git branch based on the main Git branch and
activates a related environment on Platform.sh. The new environment inherits the data
(service data and assets) of its parent environment (the production environment here).
https://docs.platform.sh/guides/symfony/get-started.html 4/9
27/9/23, 23:38 Get Started | Platform.sh Documentation
templates/default/homepage.html.twig
{% block body %}
<div class="page-header">
- <h1>{{ 'title.homepage'|trans|raw }}</h1>
+ <h1>Welcome to the Platform.sh Demo</h1>
</div>
<div class="row">
symfony cloud:deploy
Note that each environment has its own domain name. To view the domain name of your new
environment, run the following command:
5. Iterate by changing the code, committing, and deploying. When satisfied with your changes,
merge them to the main branch, deploy, and remove the feature branch:
https://docs.platform.sh/guides/symfony/get-started.html 5/9
27/9/23, 23:38 Get Started | Platform.sh Documentation
Note
Deploying to production was fast because the image built for the feat-a environment
was reused.
For a long running branch, to keep the code up-to-date with the main branch, use git merge
main or git rebase main . You can also keep the data in sync with the production
When you choose to use a third-party Git hosting service, the Platform.sh Git repository becomes
a read-only mirror of the third-party repository. All your changes take place in the third-party
repository.
BitBucket
GitHub
GitLab
Next steps
Symfony integration
https://docs.platform.sh/guides/symfony/get-started.html 6/9
27/9/23, 23:38 Get Started | Platform.sh Documentation
Learn more about the Symfony integration, a set of tools and auto-configurations that makes it
easier to use Platform.sh for Symfony projects.
Environment variables
When you use the Symfony integration, more environment variables related to Symfony are
defined.
Local development
Once Symfony has been deployed on Platform.sh, you might want to set up a local development
environment.
You might find the following commands useful when using the Symfony CLI.
https://docs.platform.sh/guides/symfony/get-started.html 7/9
27/9/23, 23:38 Get Started | Platform.sh Documentation
symfony project:init
symfony cloud:domains
symfony cloud:environments
symfony cloud:push
symfony cloud:projects
symfony cloud:user:add
List variables:
symfony cloud:variables
You might find the following commands useful when using a database with your Symfony app.
https://docs.platform.sh/guides/symfony/get-started.html 8/9
27/9/23, 23:38 Get Started | Platform.sh Documentation
https://docs.platform.sh/guides/symfony/get-started.html 9/9