PHPackages                             bref/symfony-bridge - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bref/symfony-bridge

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bref/symfony-bridge
===================

Makes Symfony work on AWS Lambda with Bref

3.0.0(2mo ago)491.7M—1.5%16[9 issues](https://github.com/brefphp/symfony-bridge/issues)[1 PRs](https://github.com/brefphp/symfony-bridge/pulls)2MITPHPPHP &gt;=8.2CI passing

Since May 4Pushed 2mo ago6 watchersCompare

[ Source](https://github.com/brefphp/symfony-bridge)[ Packagist](https://packagist.org/packages/bref/symfony-bridge)[ GitHub Sponsors](https://github.com/mnapoli)[ RSS](/packages/bref-symfony-bridge/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (28)Versions (19)Used By (2)

[Bref](https://bref.sh/) runtime to run Symfony on AWS Lambda.

[![Build Status](https://github.com/brefphp/symfony-bridge/workflows/Tests/badge.svg)](https://github.com/brefphp/symfony-bridge/actions)[![Latest Version](https://camo.githubusercontent.com/e9a957f01e14330f155a140530e5813a58583984887ebfe77b6fbee54acbe99d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f627265662f73796d666f6e792d6272696467653f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bref/symfony-bridge)[![Total Downloads](https://camo.githubusercontent.com/762e8ed7619ed966c4bf890f68bb29947487d1bb9a2ea3aa4a9e45f21e610cfd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f627265662f73796d666f6e792d6272696467652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bref/symfony-bridge)

Installation
------------

[](#installation)

```
composer req bref/symfony-bridge

```

Usage
-----

[](#usage)

You only need to do one small change to quickly setup Symfony to work with Bref.

```
// src/Kernel.php

namespace App;

+ use Bref\SymfonyBridge\BrefKernel;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\RouteCollectionBuilder;

- class Kernel extends BaseKernel
+ class Kernel extends BrefKernel
{
    // ...
```

Now you are up and running.

Optimize first request
----------------------

[](#optimize-first-request)

The first HTTP request that hits your application after you deployed a new version will use a cold cache directory. Symfony now spends time building thc cache. It may take everything between 1-20 seconds depending on the complexity of the application.

Technically this happens whenever your application run on a new Lambda. That could be when you get a lot more traffic so AWS increases the resources or when AWS just decides to kill the lambda function (or server) that you are currently on. It is normal that this happens at least a handful of times every day.

To optimize the first request, one must deploy the application with a warm cache. In a simple application it means that the deploy script should include `cache:warmup`to look something like this:

```
# Install dependencies
composer install --classmap-authoritative --no-dev --no-scripts

# Warmup the cache
bin/console cache:clear --env=prod

# Disable use of Dotenv component
echo "
