> ## Documentation Index
> Fetch the complete documentation index at: https://developer.upsun.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get started

> See how to get started deploying Symfony on Upsun.


export const GuidesRequirements = ({name}) => {
  const isSymfony = name === "Symfony";
  return <>
      <h2>Before you begin</h2>
      <p>You need:</p>
      <ul>
        <li>
          <a href="https://git-scm.com/downloads">Git</a>.{' '}
          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.
        </li>
        <li>
          An Upsun account.{' '}
          If you don't already have one, <a href="https://auth.upsun.com/register">register for a trial account</a>.{' '}
          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 Upsun account later.
        </li>
        <li>
          The {isSymfony ? <a href="https://symfony.com/download">Symfony CLI</a> : <a href="/cli">Upsun CLI</a>}.{' '}
          This lets you interact with your project from the command line.
          You can also do most things through the <a href="/docs/administration/web">Web Console</a>.
        </li>
      </ul>
    </>;
};

export const VariableBlock = ({name}) => {
  return <var spellCheck={false} title={`Replace '${name}' with your own data`}>{name}</var>;
};

Upsun is the official [Symfony](https://symfony.com/) PaaS.
This guide provides instructions for deploying, and working with, Symfony on Upsun.

<GuidesRequirements name="Symfony" />

<Note>
  The Symfony CLI wraps the [Upsun CLI](/cli) with added features related to Symfony.
  So when using Symfony, you can replace `upsun <command>` by `symfony upsun:<command>` in all of your commands.
</Note>

## 1. Create your Symfony app

To get familiar with Upsun, create a new Symfony project from scratch.
The present tutorial uses the [Symfony Demo](https://symfony.com/doc/current/setup.html#the-symfony-demo-application) app as an example :

```bash Terminal theme={null}
symfony new <PROJECT_NAME> --demo --upsun
cd <PROJECT_NAME>
```

The `--demo` flag pulls the [Symfony Demo skeleton](https://github.com/symfony/demo).<br />
The `--upsun` flag automatically generates the Upsun configuration file.

<Note>
  Alternatively, you can deploy an **existing Symfony project**.
  To do so, follow these steps:

  1. To generate a sensible default Upsun configuration,
     run the following command from within the project's directory:

     ```bash Terminal theme={null}
     symfony project:init --upsun
     ```

     This generates the `.upsun/config.yaml` and `php.ini` configuration files.

  2. Add and commit your changes:

     ```bash Terminal theme={null}
     git add .upsun/config.yaml php.ini
     git commit -m "Add Upsun configuration"
     ```
</Note>

## 2. Create your Upsun project

To create a project on Upsun, run the following command from within the project's directory:

```bash Terminal theme={null}
symfony upsun:create --title PROJECT_TITLE --set-remote
```

The `--set-remote` flag sets the new project as the remote for this repository.

<Note>
  <h4>Tip</h4>
  You can link any repository to an existing Upsun project using the following command:

  ```bash Terminal theme={null}
  symfony upsun:set-remote <PROJECT_ID>
  ```
</Note>

## 3. Deploy your project

To deploy your project, run the following command:

```bash Terminal theme={null}
symfony upsun:deploy
```

During deployment, the logs from the Upsun 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 upsun:activity:log`.

Congratulations, your first Symfony app has been deployed on Upsun!

<Info>
  <h4>Tip</h4>
  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 Upsun](/docs/administration/web/configure-project#domains),
  or run the following command:

  ```bash Terminal theme={null}
  symfony upsun:domain:add <YOUR_DOMAIN>
  ```
</Info>

## 4. Make changes to your project

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.

To make changes to your project, follow these steps:

1. Create a new environment (a Git branch) to make changes without impacting production:

   ```bash Terminal theme={null}
   symfony upsun:branch feat-a
   ```

   This command creates a new local `feat-a` Git branch based on the main Git branch,
   and activates a related environment on Upsun.
   The new environment inherits the data (service data and assets) of its parent environment (the production environment here).

2. Make changes to your project.

   For example, if you created a Symfony Demo app,
   edit the `templates/default/homepage.html.twig` template and make the following visual changes:

   ```html {location="templates/default/homepage.html.twig", no-copy="true"} theme={null}
   {% block body %}
       <div class="page-header">
   -        <h1>{{ 'title.homepage'|trans|raw }}</h1>
   +        <h1>Welcome to the Upsun Demo</h1>
       </div>

       <div class="row">

   ```

3. Add and commit your changes:

   ```bash Terminal theme={null}
   git commit -a -m "Update text"
   ```

4. Deploy your changes to the `feat-a` environment:

   ```bash Terminal theme={null}
   symfony upsun:deploy
   ```

   Note that each environment has its own domain name.
   To view the domain name of your new environment, run the following command:

   ```bash Terminal theme={null}
   symfony upsun:url --primary
   ```

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:

   ```bash Terminal theme={null}
   git checkout main
   git merge feat-a
   symfony environment:delete feat-a
   git branch -d feat-a
   symfony upsun:deploy
   ```

   Note that deploying to production is fast because the image built for the `feat-a` environment is reused.

   For a long running branch, keep the code up-to-date with the main branch by using `git merge main` or `git rebase main`.
   Also, keep the data in sync with the production environment by using `symfony upsun:env:sync`.

## 5. Optional: Use a third-party Git provider

When you choose to use a third-party Git hosting service,
the Upsun Git repository becomes a read-only mirror of the third-party repository.
All your changes take place in the third-party repository.

Add an integration to your existing third-party repository:

* [BitBucket](/docs/integrations/source/bitbucket)
* [GitHub](/docs/integrations/source/github)
* [GitLab](/docs/integrations/source/gitlab)
