Laravel Bridge
Back to home
On this page
Connect your Laravel-based app to Upsun Fixed with the platformsh/laravel-bridge library.
Laravel expects all configuration to come in through environment variables with specific names in a specific format. Upsun Fixed provides configuration information as environment variables in a different specific format. This library handles mapping the Upsun Fixed variables to the format Laravel expects for common values.
Usage
Require this package using Composer. When Composer’s autoload is included, this library is activated and the environment variables set.
composer require platformsh/laravel-bridgeMake sure to clear the cache on relevant Upsun Fixed environments afterwards.
php artisan optimize:clear What is mapped
-
If an Upsun Fixed relationship named
databaseis defined, it is taken as an SQL database and mapped to theDB_*environment variables for Laravel. -
If an Upsun Fixed relationship named
rediscacheis defined, it is mapped to theREDIS_*environment variables for Laravel. TheCACHE_DRIVERvariable is also set toredisto activate it automatically. -
If an Upsun Fixed relationship named
redissessionis defined, theSESSION_DRIVERis set toredisand theREDIS_*variables set based on that relationship. NOTE: This means you must set 2 relationships to the same Redis service and endpoint, as Laravel reuses the same backend connection. -
The Laravel
APP_KEYis set based on thePLATFORM_PROJECT_ENTROPYvariable, which is provided for exactly this purpose. -
The Laravel
APP_URLvariable is set based on the current route, when possible. -
The
SESSION_SECURE_COOKIEvariable is set totrueif it’s not already defined. An Upsun Fixed environment is by default encrypted-always, so there’s no reason to allow unencrypted cookies. Overwrite this by setting the Upsun Fixed variableenv:SESSION_SECURE_COOKIEto 0. -
The
MAIL_DRIVER,MAIL_HOST, andMAIL_PORTvariables are set to support sending email through the Upsun Fixed mail gateway. TheMAIL_ENCRYPTIONvalue is also set to0to disable TLS, as it isn’t needed or supported within Upsun Fixed’s network. Note that doing so is only supported on Laravel 6.0.4 and later. On earlier versions, you must manually modifymail.phpand setencryptiontonull:'encryption' => null,
Common environment variables not set
Laravel provides reasonable defaults for many environment variables already
and this library doesn’t override those.
Customize them by setting an Upsun Fixed variable named env:ENV_NAME.
(Note the env: prefix.)
The variables you are most likely to want to override are:
env:APP_NAME: The human-friendly name of the app.env:APP_ENV: Whether the app is inproductionordevelopmentmode.env:APP_DEBUG: Settrueto enable verbose error messages.
Now that your Laravel app is connected to Upsun Fixed, deploy it to see it in action.