Skip to content

Environment Variables

Your application receives configuration through environment variables. SKE assembles these from multiple sources with a defined precedence order.

SKE assembles each deploy’s variables in this order, a later source winning over an earlier one:

  1. Runtime defaults — the Laravel runtime’s own settings, such as LOG_CHANNEL=stderr, QUEUE_CONNECTION=ske and CACHE_PREFIX, plus the variables of an attached database and cache. With a cache attached it sets CACHE_STORE=redis. Without a database it sets SESSION_DRIVER=cookie, and CACHE_STORE=file when there is no cache either.
  2. Engine variables — what the cloud engine derives from the environment’s stack: APP_URL, ASSET_URL and the queue variables, plus FILESYSTEM_DISK and AWS_BUCKET when the environment has storage.
  3. Service variables — those of services enabled on the environment.
  4. Secrets — set via ske secret set or ske secret import, or on the environment’s Secrets tab, stored encrypted in your cloud provider.
  5. Platform variables — SKE_* variables that say which runtime, environment and provider the function is. Nothing overrides these.
Platform SKE_* > Secrets > Service variables > Engine variables > Runtime defaults

A secret overrides any injected variable of the same name. Setting DB_PASSWORD, DB_HOST or another DB_* secret replaces the attached database’s value, and setting AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY replaces the credentials of the function’s role. Only set them when you mean to.

To set a non-sensitive value per environment, set it as a secret too: the application reads it the same way.

Variable Source Example
APP_URL The first wired custom domain, else the provider URL https://abc123.execute-api.us-east-1.amazonaws.com
ASSET_URL The deployment’s assets on the CDN https://d111111abcdef8.cloudfront.net/…
DB_CONNECTION Attached database mysql or pgsql
DB_HOST Attached database my-db.abc123.us-east-1.rds.amazonaws.com
DB_PORT Attached database 3306
DB_DATABASE Attached database my_app
DB_USERNAME Attached database ske
DB_PASSWORD Attached database (generated)
REDIS_HOST Attached cache (tls:// in front when the cache uses TLS) tls://my-cache.abc123.cache.amazonaws.com
REDIS_PORT Attached cache 6379
REDIS_PREFIX Attached cache <environment prefix>:database:
CACHE_STORE Attached cache, else file without a database redis
REDIS_CACHE_DB Attached serverless cache 0
CACHE_PREFIX Runtime <environment prefix>:cache:
QUEUE_CONNECTION Runtime ske
SQS_PREFIX Queues (AWS) https://sqs.us-east-1.amazonaws.com/123456789012
SQS_QUEUE Queues (AWS) default
SQS_SUFFIX Queues (AWS) --<environment prefix>
SKE_QUEUE_PREFIX Queues (GCP) The Cloud Tasks queue name prefix
FILESYSTEM_DISK, AWS_BUCKET Storage (AWS) s3, the bucket name

These are set automatically when you attach a database or cache, add queues or storage. You don’t need to set them manually.

With a cache attached, it is Laravel’s cache store (CACHE_STORE=redis). On a node-based cache the cache store uses Redis database 1, Laravel’s default. A serverless cache has only database 0, so there SKE sets REDIS_CACHE_DB=0 and the cache store shares it with everything else the app keeps in Redis.

php artisan cache:clear empties the whole Redis database the cache store is on, not only this environment’s keys. Every environment attached to the same cache loses its cached data, and on a serverless cache so does anything else in Redis, such as locks and sessions. Where that matters, give each environment its own cache.

Sessions stay where they were: in the database when there is one, otherwise in the cookie (SESSION_DRIVER=cookie), as a cache may evict keys and cache:clear empties it. To keep sessions in the cache, set SESSION_DRIVER=redis as a secret. With neither a database nor a cache, the cache store is file, on the function’s temporary disk, so each instance has its own. A CACHE_STORE, REDIS_CACHE_DB or SESSION_DRIVER secret wins over these.

APP_KEY is created for you when the environment is created. Set the values your app needs that SKE doesn’t know:

Terminal window
ske secret set MAIL_PASSWORD
ske secret set STRIPE_SECRET
ske secret set SENTRY_DSN