Documentation
¶
Overview ¶
Package envfile provides helpers for reading and updating .env files while preserving comments, blank lines, and line order.
Index ¶
- func ApplyPhpConstUpdates(path string, updates map[string]string) error
- func ApplyUpdates(path string, updates map[string]string) error
- func ReadKey(path, key string) string
- func ReadKeys(path string) ([]string, error)
- func ReadPhpConst(path string) (map[string]string, error)
- func UpdateAppURL(projectPath, scheme, domain string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyPhpConstUpdates ¶ added in v1.0.0
ApplyPhpConstUpdates rewrites define() values in a PHP file for the given keys. Existing define() calls are updated in-place. Keys that don't exist in the file are appended before "/* That's all" comment, or at the end of the file if not found.
func ApplyUpdates ¶
ApplyUpdates rewrites the .env at path, replacing values for any key in updates. Keys not already present are appended at the end. Comments and blank lines are preserved.
func ReadKey ¶ added in v0.6.0
ReadKey returns the value of a single key from the .env file at path, or an empty string if the key is absent or the file cannot be read.
func ReadKeys ¶ added in v1.5.0
ReadKeys returns all non-comment key names from the .env file at path, in the order they appear.
func ReadPhpConst ¶ added in v1.0.0
ReadPhpConst reads a WordPress-style wp-config.php file and returns a map of the defined PHP constants (define('KEY', 'value') calls). Only string and numeric constants are captured; boolean/null defines are ignored.
func UpdateAppURL ¶
UpdateAppURL sets APP_URL in the project's .env to scheme://domain. Silently does nothing if no .env exists.
Types ¶
This section is empty.