Environment Variables
Your application receives configuration through environment variables. SKE assembles these from multiple sources with a defined precedence order.
Sources of environment variables
Section titled “Sources of environment variables”SKE assembles each deploy’s variables in this order, a later source winning over an earlier one:
- Runtime defaults — the Laravel runtime’s own settings, such as
LOG_CHANNEL=stderr,QUEUE_CONNECTION=skeandCACHE_PREFIX, plus the variables of an attached database and cache. With a cache attached it setsCACHE_STORE=redis. Without a database it setsSESSION_DRIVER=cookie, andCACHE_STORE=filewhen there is no cache either. - Engine variables — what the cloud engine derives from the environment’s stack:
APP_URL,ASSET_URLand the queue variables, plusFILESYSTEM_DISKandAWS_BUCKETwhen the environment has storage. - Service variables — those of services enabled on the environment.
- Secrets — set via
ske secret setorske secret import, or on the environment’s Secrets tab, stored encrypted in your cloud provider. - 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 defaultsA 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.
Injected variables
Section titled “Injected variables”| 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.
Common variables to set as secrets
Section titled “Common variables to set as secrets”APP_KEY is created for you when the environment is created. Set the values your app needs that SKE doesn’t know:
ske secret set MAIL_PASSWORDske secret set STRIPE_SECRETske secret set SENTRY_DSN