-
You run the
symfony newcommand with the--upsunoption -
You run
symfony project:init --upsunon an existing project to automatically generate the Upsun configuration
.upsun/config.yaml
- It installs some helper scripts that you can use as the default build and deploy hook scripts:
- It adds some extra tools
- It defines additional infrastructure environment variables and environment variables for all services
Tools
The configurator (curl -fs https://get.symfony.com/cloud/configurator | bash) is a script specially crafted for Upsun.
It ensures that projects are always using the latest version of the following tools:
- croncape for cron feedback
- Symfony CLI
- Composer
Hooks
Thehooks section defines the scripts that Upsun runs at specific times of an application lifecycle:
- The build hook is run during the build process
- The deploy hook is run during the deployment process
- The post-deploy hook is run after the deploy hook, once the application container starts accepting connections
hooks section optimized for Symfony projects:
.upsun/config.yaml
Warning
As each hook is executed as a single script, a hook is considered as failed only if the final command fails. To have your hooks fail on the first failed command, start your scripts withset -e.Tip
During thedeploy or post_deploy hooks, you can execute actions for a specific environment type only.
To do so, in your .upsun/config.yamlfile,
use the PLATFORM_ENVIRONMENT_TYPE environment variable) in a condition:.upsun/config.yaml
symfony-build
symfony-build is the script that builds a Symfony app in an optimized way for Upsun. Use it as the main build script in yourbuild hook.
symfony-build performs the following actions:
- Removes the development frontend file (Symfony <4)
- Installs PHP extensions through the
php-ext-installscript - Installs application dependencies using Composer
- Optimizes the autoloader
- Builds the Symfony cache in an optimized way to limit the time it takes to deploy
- Installs the JavaScript dependencies via npm or Yarn
- Builds the production assets using Encore
$COMPOSER_FLAGS environment variable:
.upsun/config.yaml
NO_NPM or NO_YARN to 1 depending on your package manager.
To customize Node/npm/Yarn behaviors,
prefix the symfony-build script with the following environment variables:
NODE_VERSION: to pinpoint the Node version that nvm is going to install. The default value is--lts.YARN_FLAGS: flags to pass toyarn install. There is no default value.
symfony-deploy
Use symfony-deploy as the main deploy script in thedeploy hook.
It only works if you’re using the symfony-build script in your build hook.
symfony-deploy performs the following actions:
- Replaces the Symfony cache with the cache generated during the build hook
- Migrates the database when the Doctrine migration bundle is used
php-ext-install
You can use the php-ext-install script to compile and install PHP extensions not provided out of the box by Upsun, or when you need a specific version of an extension. The script is written specifically for Upsun to ensure fast and reliable setup during the build step. php-ext-install currently supports three ways of fetching sources:- From PECL:
php-ext-install redis 5.3.2 - From a URL:
php-ext-install redis https://github.com/phpredis/phpredis/archive/5.3.2.tar.gz - From a Git repository:
php-ext-install redis https://github.com/phpredis/phpredis.git 5.3.2
php-ext-install after the configurator
but before symfony-build:
.upsun/config.yaml
.upsun/config.yaml
The source code is cached between builds so compilation is skipped if it’s already been done.
Changing the source of downloads or the version invalidates this cache.
Advanced Node configuration
If you need to use the Node installation setup by symfony-build, use the following configuration:.upsun/config.yaml
.upsun/config.yaml