Static Methodvapor 4.114.1Vapor

read(path:fileio:on:)

Reads a dotenv file from the supplied path.

DotEnv.swift:179

This declaration is deprecated: Migrate to async API

static func read(path: String, fileio: NonBlockingFileIO, on eventLoop: EventLoop) -> EventLoopFuture<DotEnvFile>

Parameters

path

Absolute or relative path of the dotenv file.

fileio

File loader.

eventLoop

Eventloop to perform async work on.

let fileio: NonBlockingFileIO
let elg: EventLoopGroup
let file = try DotEnvFile.read(path: ".env", fileio: fileio, on: elg.next()).wait()
for line in file.lines {
    print("\(line.key)=\(line.value)")
}
file.load(overwrite: true) // loads all lines into the process
print(Environment.process.FOO) // BAR

Use DotEnvFile.load to read and load with one method.