FileSystemEnvRepository
in package
FileSystem repository for .env file operations.
Provides file system access for database connection wizard. This class operates independently of the database.
Tags
Table of Contents
Properties
- $envPath : string
- Path to the .env file.
Methods
- __construct() : mixed
- Constructor.
- exists() : bool
- Check if .env file exists.
- getAutocompleteSuggestions() : DatabaseConnectionDTO
- Get autocomplete values from server environment.
- getPath() : string
- Get .env file path.
- load() : DatabaseConnectionDTO
- Load connection from .env file.
- save() : bool
- Save connection to .env file.
- testConnection() : array{success: bool, error: ?string}
- Test a database connection.
- quoteEnvValue() : string
- Quote an env value for safe storage.
- unquoteEnvValue() : string
- Unquote an env value when loading.
Properties
$envPath
Path to the .env file.
private
string
$envPath
Methods
__construct()
Constructor.
public
__construct([string|null $basePath = null ]) : mixed
Parameters
- $basePath : string|null = null
-
Base path for .env file (default: LWT root)
exists()
Check if .env file exists.
public
exists() : bool
Return values
bool —True if file exists
getAutocompleteSuggestions()
Get autocomplete values from server environment.
public
getAutocompleteSuggestions() : DatabaseConnectionDTO
Return values
DatabaseConnectionDTO —Pre-filled connection data
getPath()
Get .env file path.
public
getPath() : string
Return values
string —Path to .env file
load()
Load connection from .env file.
public
load() : DatabaseConnectionDTO
Return values
DatabaseConnectionDTO —Connection data
save()
Save connection to .env file.
public
save(DatabaseConnectionDTO $dto) : bool
Parameters
- $dto : DatabaseConnectionDTO
-
Connection data to save
Return values
bool —True on success
testConnection()
Test a database connection.
public
testConnection(DatabaseConnectionDTO $dto) : array{success: bool, error: ?string}
Parameters
- $dto : DatabaseConnectionDTO
-
Connection data to test
Return values
array{success: bool, error: ?string}quoteEnvValue()
Quote an env value for safe storage.
private
quoteEnvValue(string $value) : string
Always uses double quotes and escapes special characters.
Parameters
- $value : string
-
Raw value
Return values
string —Quoted and escaped value
unquoteEnvValue()
Unquote an env value when loading.
private
unquoteEnvValue(string $value) : string
Handles both single and double quoted values, and unescapes characters.
Parameters
- $value : string
-
Quoted value from .env file
Return values
string —Unquoted and unescaped value