Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
71 lines (53 sloc) 2.33 KB
title currentMenu introduction previous
Console applications
Learn how to run serverless console commands on AWS Lambda with Symfony Console or Laravel Artisan.
link title
HTTP applications

Bref provides a way to run console commands on AWS Lambda.

This can be used to run the Symfony Console, Silly or Laravel Artisan commands in production.


The lambda function used for running console applications must use two Lambda layers:

  • the base PHP layer (the PHP runtime that provides the php binary)
  • the "console" layer that overrides the base runtime to execute your console application

Below is a minimal template.yaml. To create it automatically run vendor/bin/bref init and select "Console application".

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
        Type: AWS::Serverless::Function
            FunctionName: 'my-function'
            CodeUri: .
            Handler: bin/console # or `artisan` for Laravel
            Runtime: provided
                # PHP runtime
                - 'arn:aws:lambda:<region>:209497400698:layer:php-73:<version>'
                # Console layer
                - 'arn:aws:lambda:<region>:209497400698:layer:console:<version>'


To run a console command on AWS Lambda use bref cli:

vendor/bin/bref cli <function-name> -- <command>

<function-name> is the name of the function defined in template.yaml. In our example above that would be my-function.

Pass your command, arguments and options by putting them after --. The -- delimiter separates between options for the bref cli command (before --) and your command (after --).

vendor/bin/bref cli my-function <bref options> -- <your command, your options>

For example:

# Runs the CLI application without arguments and displays the help
$ vendor/bin/bref cli my-function
# ...

$ vendor/bin/bref cli my-function -- doctrine:migrate
Your database will be migrated.
To execute the SQL queries run the command with the `--force` option.

$ vendor/bin/bref cli my-function -- doctrine:migrate --force
Your database has been migrated.
You can’t perform that action at this time.