Configuration
Configuration parameters are set in the .env
file. Their use should be via the os.GetEnv()
function. However, there is also a generic function utils.GetEnv()
from module "app/core/utils"
that differs from the utilities in terms of default value.
NoteTIP
Using utils.GetEnv() will help you immediately get the data type you need. No additional conversion operations are required. Examples:
- Get string
utils.Getenv("REDIS_HOST", "localhost")
- Get number
utils.Getenv("REDIS_PORT", 6379)
- Get boolean
utils.Getenv("NOTIFICATION_ENABLE", false)
When you first start with gFly. You only need to care about the two available files .env.example
used for running gFly directly locally. The .env.docker
file is used for running gFly using Docker.
They have their own initial settings to help you run applications with gFly without understanding anything about the configuration parameters inside gFly. However, they are still a completely identical set of parameters, as follows:
# NOTE: Application settings:
# App environment to start server:
# - "local" Local env
# - "dev" Dev env
# - "stag" Staging env
# - "prod" Production env
APP_NAME="gFly"
APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost:7789
# NOTE: Server settings:
SERVER_HOST="0.0.0.0"
SERVER_PORT=7789
# NOTE: TLS settings:
#SERVER_TLS_CERT=./resources/tls/localhost.crt
#SERVER_TLS_KEY=./resources/tls/localhost.key
SERVER_TLS_CERT=
SERVER_TLS_KEY=
# NOTE: Static settings:
STATIC_PATH=public
# NOTE: API settings:
API_PREFIX=api
API_VERSION=v1
API_NAME="gFly API"
# NOTE: Database settings:
# DB_DRIVER:
# - "" EMPTY is disable DB connection
# - "mysql" Mysql driver
# - "postgresql" PostgreSQL driver
DB_DRIVER=
DB_HOST="db"
DB_PORT=3306
DB_NAME="gfly"
DB_USERNAME="user"
DB_PASSWORD=secret
DB_SSL_MODE="disable"
DB_MAX_CONNECTION=100
DB_MAX_IDLE_CONNECTION=10
DB_MAX_LIFETIME_CONNECTION=2
# NOTE: Mail settings:
MAIL_PROTOCOL=smtp
MAIL_HOST=mail
MAIL_PORT=1025
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_SENDER=no-reply@gfly.dev
MAIL_NAME="gFly - No Reply"
# NOTE: SMS Settings:
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
# NOTE: Slack Settings:
SLACK_CHANNEL=
# NOTE: Redis settings:
REDIS_HOST="redis"
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_DB_NUMBER=0
REDIS_QUEUE_NUMBER=1
# NOTE: Session setting:
# SESSION_TYPE:
# - "" EMPTY is disable Session
# - "memory" memory provider (Default).
# - "redis" redis provider.
# SESSION_TTL minutes
SESSION_TYPE=
SESSION_KEY=gfly_session
SESSION_TTL=30
SESSION_ID=gflyid
# NOTE: View Template settings:
VIEW_PATH=./resources/views
VIEW_EXT=tpl
# NOTE: Storage file system settings:
# FILESYSTEM_TYPE:
# - "local" Local storage (Default).
# - "s3" S3 storage.
FILESYSTEM_TYPE=local
STORAGE_DIR=./storage
LOG_DIR=./storage/log
APP_DIR=./storage/app
TEMP_DIR=./storage/tmp
# NOTE: Log settings:
# - Trace|Debug|Info|Warn|Error|Fatal|Panic
LOG_CHANNEL=file
LOG_FILE=logs.log
LOG_LEVEL=Trace
# NOTE: AWS settings:
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-west-1
AWS_BUCKET=902-local
AWS_USE_PATH_STYLE_ENDPOINT=false
# NOTE: OAuth settings:
# Providers: Facebook | Google | Github
# Disable by emptying one of three parameters of a group.
OAUTH_FACEBOOK_KEY=
OAUTH_FACEBOOK_SECRET=
OAUTH_FACEBOOK_CALLBACK=
OAUTH_GOOGLE_KEY=
OAUTH_GOOGLE_SECRET=
OAUTH_GOOGLE_CALLBACK=
OAUTH_GITHUB_KEY=
OAUTH_GITHUB_SECRET=
OAUTH_GITHUB_CALLBACK=
# NOTE: Notification settings:
NOTIFICATION_ENABLE=true
APP_NAME="gFly"
APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost:7789
- Parameter
APP_NAME
is simply the application name you need to set. - Parameter
APP_ENV
is the current environment in which the application is running. Currently there are 4 environments you can choose from:local
,dev
,stag
,prod
. Note: Accurately recording running environments will help perform application functions and support and management tools correctly. - Parameter
APP_DEBUG
helps to run corresponding process for development and debugging purposes. Valuetrue
is not recommended in production environments (When APP_ENV isprod
). - Parameter
APP_URL
should be a public URL value.
SERVER_HOST="0.0.0.0"
SERVER_PORT=7789
- The default
SERVER_HOST
parameter is0.0.0.0
so the application can accept requests from anywhere. - Parameter
SERVER_PORT
default port7789
.
SERVER_TLS_CERT=./resources/tls/localhost.crt
SERVER_TLS_KEY=./resources/tls/localhost.key
To support SSL at the local env, we have made available TLS files.
For Mac environment. You should run the following to add a trusted certificate to Mac.
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain localhost.crt
Disable TLS by setting EMPTY
values:
SERVER_TLS_CERT=
SERVER_TLS_KEY=
If you want to create a new TLS. Please check at
STATIC_PATH=public
Static resource will put into folder ./public/
. To serve static files such as images, CSS, JavaScript and HTML files, and more.
API_PREFIX=api
API_VERSION=v1
API_NAME="gFly API"
- If the application serves both Web and API. So, we need the prefix API parameter
API_PREFIX
. - Many API versions can be used in the application. So, we need to indicate that the parameter
API_VERSION
is the way to know the current version. - Parameter
API_NAME
to help label the API document.
DB_DRIVER=
DB_HOST="db"
DB_PORT=3306
DB_NAME="gfly"
DB_USERNAME="user"
DB_PASSWORD="secret"
DB_SSL_MODE="disable"
DB_MAX_CONNECTION=100
DB_MAX_IDLE_CONNECTION=10
DB_MAX_LIFETIME_CONNECTION=2
- Parameter
DB_DRIVER
has value""
(Call<EMPTY>
value) if you want to disable Database connection. gFly supports 2 Database driversmysql
andpostgresql
. - Parameter
DB_HOST
is the Database server value. - Parameter
DB_PORT
is the Database port value. - Parameter
DB_NAME
is the Database name value. - Pair parameters
DB_USERNAME
andDB_PASSWORD
is credentials to connect to Database. - Parameters
DB_MAX_CONNECTION
,DB_MAX_IDLE_CONNECTION
,DB_MAX_LIFETIME_CONNECTION
come from libgithub.com/jmoiron/sqlx
. Refer SQLX
MAIL_PROTOCOL=smtp
MAIL_HOST=mail
MAIL_PORT=1025
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_SENDER=no-reply@gfly.dev
MAIL_NAME="gFly - No Reply"
- Parameter
MAIL_PROTOCOL
issmtp
. The default protocol for mailing in gFly. - Parameter
MAIL_HOST
is Mail host. - Parameter
MAIL_PORT
is Mail port number. - Pair parameters
MAIL_USERNAME
andMAIL_PASSWORD
is credentials to connect to Mail server. - Parameter
MAIL_SENDER
is sender’s email for all mail sent out. - parameter
MAIL_NAME
is the sender’s email name.
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
Parameters used for notification
function. It supports for notifications via SMS
channel.
Note: Set <EMPTY>
value if you want to disable SMS
notification.
SLACK_CHANNEL=
Parameter used for notification
function. It supports for notifications via Slack
channel.
Note: Set <EMPTY>
value if you want to disable Slack
notification.
REDIS_HOST="redis"
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_DB_NUMBER=0
REDIS_QUEUE_NUMBER=1
- Parameter
REDIS_HOST
is Redis server. - Parameter
REDIS_PORT
is Redis port number. - Parameter
REDIS_PASSWORD
is Redis password. - Parameter
REDIS_DB_NUMBER
is DB number. - Parameter
REDIS_QUEUE_NUMBER
is DB number for Queue system. Note: Currently, gFly only support queue via Redis.
SESSION_TYPE=redis
SESSION_KEY=gfly_session
SESSION_TTL=30
SESSION_ID=gflyid
- Parameter
SESSION_TYPE
has value""
if you want to disable session. gFly supports 2 session storagesmemory
andredis
. - Parameter
SESSION_KEY
is session key. It helps to us easy to monitor session data when useredis
storage. - Parameter
SESSION_TTL
is Time To Live for a user’s session. Unit is minute. - Parameter
SESSION_ID
is cookie name related to session.
VIEW_PATH=./resources/views
VIEW_EXT=tpl
- Parameter
VIEW_PATH
is folder to store template files. - Parameter
VIEW_EXT
is extension of template file. Value istpl
.
FILESYSTEM_TYPE=local
STORAGE_DIR=./storage
LOG_DIR=./storage/log
APP_DIR=./storage/app
TEMP_DIR=./storage/tmp
- Parameter
FILESYSTEM_TYPE
is folder to store template files. gFly supports 2 file storageslocal
ands3
. - Parameter
STORAGE_DIR
is folder to store file. - Parameter
LOG_DIR
is folder to store log file. - Parameter
APP_DIR
is folder to store app file. - Parameter
TEMP_DIR
is folder to store temporary file.
# NOTE: Log settings:
# - Trace|Debug|Info|Warn|Error|Fatal|Panic
LOG_CHANNEL=file
LOG_FILE=logs.log
LOG_LEVEL=Trace
- Parameter
LOG_CHANNEL
is log channel. Only supportfile
channel. - Parameter
LOG_FILE
is log file format. - Parameter
LOG_LEVEL
is log level.
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-west-1
AWS_BUCKET=902-local
AWS_USE_PATH_STYLE_ENDPOINT=false
AWS setting for S3 and other services.
OAUTH_FACEBOOK_KEY=
OAUTH_FACEBOOK_SECRET=
OAUTH_FACEBOOK_CALLBACK=
OAUTH_GOOGLE_KEY=
OAUTH_GOOGLE_SECRET=
OAUTH_GOOGLE_CALLBACK=
OAUTH_GITHUB_KEY=
OAUTH_GITHUB_SECRET=
OAUTH_GITHUB_CALLBACK=
There are 3 OAuth providers: Facebook
, Google
and Github
. To install a provider, you need 3 parameters. Example: OAUTH_FACEBOOK_KEY
, OAUTH_FACEBOOK_SECRET
, OAUTH_FACEBOOK_CALLBACK
for Facebook.
NOTIFICATION_ENABLE=true
- Parameter
NOTIFICATION_ENABLE
to enable or disable notification.