Install Tool

Spryker offers an install tool which can be used to install the system as described in the install recipe file(s).

Installation

Install the module with composer by running the following command:


        composer require spryker/install
        

After the installation you can run the command with vendor/bin/install. Use the -h option to see the help page for this command.

Configuration

The way Spryker should be installed is described in a *.yml file. You can have as much configuration files as you want e.g. development.yml, staging.yml etc. These files are called recipe.

It is also possible to have only local used recipes. Those local recipes are named *_local.yml. This is useful for different departments working with Spryker. Your frontend developer could have a frontend_local.yml where only all frontend related things are executed.

All recipes have to be placed into the {ROOT}/config/install/ directory.

The recipe is divided into blocks we will describe later in this document.

Environment Variables

You can specify environment variables used for the installation. Those key value pairs are exported in the beginning of the installation with putenv("KEY=value"). This block is mainly used to define the environment the install tool should run in. E.g. APPLICATION_ENV: development

Example:


env:
  KEY1: value1
  KEY2: value2

Stores

You can specify all stores for which you want to run the install tool. When commands are marked as "store aware", the install tool will run the command for all specified stores. By default the install tool runs only the in your application-configured default store.

Example:


store:
  - DE
  - AT
  - US

Command timeout

You can specify the command timeout limit in seconds for all commands defined per recipe.

Example:


command-timeout: 3600 # Set timeout of every command to 3600 seconds.

Sections

You can have one or more section(s) in your configuration file. A section is a set of commands related to one topic. It is also possible to add "default excluded" sections, this is useful for sections which you only want to run in specific cases or when you want to run some commands only as pre or post command. Those default excluded sections are not executed until you "request" them to be executed. For more details about execution, look into How to Execute the Install Tool section below.

Example:


...
sections:
  section-a:
    excluded: true (default false)
    command-a: ...
    command-b: ...
    command-c: ...

  section-b:
    command-a: ...
    command-b: ...
    command-c: ...

  section-c:
    pre: "section-name/command-name"
    post: "section-name/command-name"
    command-a: ...
    command-b: ...
    command-c: ...
...

Pre and Post

You can specify pre and post commands for each of your sections. The value for pre and post is a pair of the section name and the command name. The pre command is executed before any other command of the section is executed. The post command is executed after all other commands of the section are executed. This is very useful when you have commands which are not executed only once. When a command has a complex configuration, you only need to add it once and can run it at any time in your installation.

Commands

Each section contains one or more command(s) to be executed. The Command must be a string which can be executed on the command line. Internally we use Symfony's Process to execute those commands.

Example:


...
sections:
  section-a:
    command-a: # name of the command
      excluded: true (default false)
      command: "vendor/bin/console your:command-a"

    command-b:
      command: "vendor/bin/console your:command-b"
      groups:
        - group-a
        - group-b

    command-c:
      command: "vendor/bin/console your:command-c"
      env:
        KEY1: value1
        KEY2: value2

    command-d:
      command: "vendor/bin/console your:command-d"
      stores: true

    command-e:
      command: "vendor/bin/console your:command-e"
      conditions:
        - command: "command-e"
          ifExitCode: 3

    command-f:
      pre: "section-name/command-name"
      post: "section-name/command-name"
      command: "vendor/bin/console your:command-f"

    command-g:
      command: "vendor/bin/console your:command-g"
      timeout: 300 # Set command timeout to 300 seconds.
...

Excluded

The excluded option can be used to mark a command as excluded, default is false. When a command is marked as excluded, it will not run until you request it to run. There are many ways to run the setup, for more details look into How to Execute the Install Tool section below.

Groups

Groups can be used to group several commands of several sections to make them executable in one shot.

Env

With the env option you can add additional environment variables which are exported with putenv("KEY=value"). After the command is executed those will be unset with putenv("KEY").

Stores

When the option is set to true, the command will be run for all stores configured in the recipe. It is also possible to use a list of stores. Imagine you have three of stores, e.g DE, AT and US, and you want to share the database for the DE store with the one for AT. To not import the data for DE and AT twice into the same database, you can use a list with the store names the command should run for. In this example for DE and US.

Conditions

Conditions can be used when you want to run a command only when another command fulfills the condition. Currently we support ifExitCode and ifNotExitCode.

Pre and Post

You can specify pre and post commands for each of your commands. The value for pre and post is a pair of the section name and the command name. The pre command is executed before the command is executed. The post command is executed after the command is executed.

How to Execute the Install Tool

There are several ways to execute the install command. The following list describes some possibilities to execute it:

  • vendor/bin/install will execute all sections and commands which are not marked as excluded.
  • vendor/bin/deploy -s section-name (-s another-section-to-run) will only execute the requested sections although they are marked as excluded.
  • vendor/bin/deploy -x section-name (-x another-section-to-exclude) will execute all sections except the excluded ones.
  • vendor/bin/deploy -g group-name (-g another-group-to-execute) will only execute the requested groups although they are marked as excluded.
  • vendor/bin/install -i will ask you which sections should be included in your install run.

For full description of the install tool options run it with -h to see the help of this command.

 

Last review date: Apr. 13th, 2018