# `PhoenixKit.Utils.PhoenixVersion`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.87/lib/phoenix_kit/utils/phoenix_version.ex#L1)

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?()
    true

## Version Strategies

- `:legacy` - Phoenix < 1.8.0, uses router-level layout configuration
- `:modern` - Phoenix >= 1.8.0, supports function component layouts

# `get_strategy`

```elixir
@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

# `get_version`

```elixir
@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"

# `get_version_info`

```elixir
@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"
    }

# `modern_version?`

```elixir
@spec modern_version?(String.t()) :: boolean()
```

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

# `requires_legacy_config?`

```elixir
@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

# `supports_function_components?`

```elixir
@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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
