Utilities for detecting and working with Phoenix framework versions.
This module provides functions to detect the Phoenix version in use and determine compatibility strategies for different Phoenix versions, particularly for layout integration between v1.7- and v1.8+.
Usage
iex> PhoenixKit.Utils.PhoenixVersion.get_version()
"1.8.2"
iex> PhoenixKit.Utils.PhoenixVersion.get_strategy()
:modern
iex> PhoenixKit.Utils.PhoenixVersion.supports_function_components?()
trueVersion Strategies
:legacy- Phoenix < 1.8.0, uses router-level layout configuration:modern- Phoenix >= 1.8.0, supports function component layouts
Summary
Functions
Gets the compatibility strategy for the current Phoenix version.
Gets the current Phoenix framework version as a string.
Gets version information for debugging and diagnostics.
Checks if a specific version string represents a modern Phoenix version.
Checks if the current Phoenix version requires legacy layout configuration.
Checks if the current Phoenix version supports function component layouts.
Functions
@spec get_strategy() :: :legacy | :modern
Gets the compatibility strategy for the current Phoenix version.
Returns either :legacy for Phoenix < 1.8.0 or :modern for Phoenix >= 1.8.0.
Examples
iex> PhoenixKit.Utils.PhoenixVersion.get_strategy()
:modern
@spec get_version() :: String.t()
Gets the current Phoenix framework version as a string.
Returns the version from the Phoenix application specification, or a fallback version if Phoenix is not found.
Examples
iex> PhoenixKit.Utils.PhoenixVersion.get_version()
"1.8.2"
@spec get_version_info() :: map()
Gets version information for debugging and diagnostics.
Returns a map with detailed version information including the raw version from the application spec and the normalized version used for comparisons.
Examples
iex> PhoenixKit.Utils.PhoenixVersion.get_version_info()
%{
raw_version: '1.8.2',
normalized_version: "1.8.2",
strategy: :modern,
supports_function_components: true,
threshold_version: "1.8.0"
}
Checks if a specific version string represents a modern Phoenix version.
Examples
iex> PhoenixKit.Utils.PhoenixVersion.modern_version?("1.8.0")
true
iex> PhoenixKit.Utils.PhoenixVersion.modern_version?("1.7.14")
false
@spec requires_legacy_config?() :: boolean()
Checks if the current Phoenix version requires legacy layout configuration.
Legacy layout configuration is required for Phoenix < 1.8.0.
Examples
iex> PhoenixKit.Utils.PhoenixVersion.requires_legacy_config?()
false
@spec supports_function_components?() :: boolean()
Checks if the current Phoenix version supports function component layouts.
Function component layouts were introduced in Phoenix 1.8.0.
Examples
iex> PhoenixKit.Utils.PhoenixVersion.supports_function_components?()
true