# sanchescom/php-wifi architecture

> Architecture diagram of the GitHub repository sanchescom/php-wifi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sanchescom/php-wifi
- Repository: https://github.com/sanchescom/php-wifi

## Overview

PHP WiFi is a cross-platform library and CLI for discovering networks, joining and disconnecting, and managing Linux hotspots. The main workflow runs from a user or application through the WiFi facade to an OS-specific backend, which invokes system tools and returns parsed immutable network values. Linux also supports a watchdog recovery loop and phone-based provisioning through a captive portal. The graph includes those documented capabilities; unsampled backend, CLI, and provisioning details are represented at their supported source paths, and links without direct relationship evidence are omitted.

Main entry points: [`src/WiFi.php`](https://github.com/sanchescom/php-wifi/blob/master/src/WiFi.php) (WiFi Facade), [`src/Shell/ShellCommandRunner.php`](https://github.com/sanchescom/php-wifi/blob/master/src/Shell/ShellCommandRunner.php) (Command Runner), [`src/Parser`](https://github.com/sanchescom/php-wifi/tree/master/src/Parser) (Output Parsers), [`src/Provision/Portal.php`](https://github.com/sanchescom/php-wifi/blob/master/src/Provision/Portal.php) (Captive Portal)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Library API"]
  node_cli["WiFi CLI<br/>[WiFiCli.php]"]
  node_facade["WiFi Facade<br/>[WiFi.php]"]
  node_values["Network Values<br/>[Network.php]"]
  node_collection["Network Collection"]
  node_exceptions["WiFi Exceptions"]
end

subgraph group_platform["Platform Backends"]
  node_factory["Backend Selection<br/>[BackendFactory.php]"]
  node_contract["Backend Contract<br/>[Backend.php]"]
  node_nmcli["NetworkManager<br/>[NmcliBackend.php]"]
  node_wpacli["wpa supplicant<br/>[WpaCliBackend.php]"]
  node_macos["macOS Backend"]
  node_windows["Windows Backend<br/>[NetshBackend.php]"]
  node_parsers["Output Parsers"]
end

subgraph group_runtime["Command Runtime"]
  node_shell["Command Model<br/>[Command.php]"]
  node_runner["Command Runner"]
  node_os["OS Detection<br/>[Os.php]"]
end

subgraph group_recovery["Recovery And Setup"]
  node_watchdog["WiFi Watchdog<br/>[Watchdog.php]"]
  node_portal["Captive Portal<br/>[Portal.php]"]
  node_setup["Setup Page<br/>[SetupPage.php]"]
  node_supervisor["Provision Supervisor<br/>[Supervisor.php]"]
end

node_user(("User / App"))
node_system{{"OS WiFi Tools"}}
node_phone(("Phone"))

node_user -->|"runs commands"| node_cli
node_user -->|"calls API"| node_facade
node_cli -->|"uses API"| node_facade
node_facade -->|"creates backend"| node_factory
node_factory -->|"selects implementation"| node_contract
node_facade -->|"delegates operations"| node_contract
node_nmcli -->|"parses output"| node_parsers
node_wpacli -->|"parses output"| node_parsers
node_macos -.->|"parses output"| node_parsers
node_windows -.->|"parses output"| node_parsers
node_nmcli -->|"runs commands"| node_runner
node_wpacli -->|"runs commands"| node_runner
node_facade -->|"returns scan results"| node_collection
node_parsers -->|"builds networks"| node_values
node_collection -->|"filters networks"| node_values
node_runner -->|"executes command"| node_shell
node_runner -->|"invokes tools"| node_system
node_facade -->|"raises capability errors"| node_exceptions
node_watchdog -->|"reconnects / raises hotspot"| node_facade
node_watchdog -->|"checks stations"| node_runner
node_cli -->|"starts provisioning"| node_supervisor
node_supervisor -.->|"coordinates setup"| node_portal
node_portal -->|"scans / joins / starts hotspot"| node_facade
node_setup -->|"renders portal responses"| node_portal
node_phone -->|"submits credentials"| node_portal

click node_cli "https://github.com/sanchescom/php-wifi/blob/master/src/Cli/WiFiCli.php"
click node_facade "https://github.com/sanchescom/php-wifi/blob/master/src/WiFi.php"
click node_values "https://github.com/sanchescom/php-wifi/blob/master/src/Value/Network.php"
click node_collection "https://github.com/sanchescom/php-wifi/blob/master/src/Value/NetworkCollection.php"
click node_exceptions "https://github.com/sanchescom/php-wifi/tree/master/src/Exception"
click node_factory "https://github.com/sanchescom/php-wifi/blob/master/src/Backend/BackendFactory.php"
click node_contract "https://github.com/sanchescom/php-wifi/blob/master/src/Backend/Backend.php"
click node_nmcli "https://github.com/sanchescom/php-wifi/blob/master/src/Backend/NmcliBackend.php"
click node_wpacli "https://github.com/sanchescom/php-wifi/blob/master/src/Backend/WpaCliBackend.php"
click node_macos "https://github.com/sanchescom/php-wifi/blob/master/src/Backend/NetworksetupBackend.php"
click node_windows "https://github.com/sanchescom/php-wifi/blob/master/src/Backend/NetshBackend.php"
click node_parsers "https://github.com/sanchescom/php-wifi/tree/master/src/Parser"
click node_shell "https://github.com/sanchescom/php-wifi/blob/master/src/Shell/Command.php"
click node_runner "https://github.com/sanchescom/php-wifi/blob/master/src/Shell/ShellCommandRunner.php"
click node_os "https://github.com/sanchescom/php-wifi/blob/master/src/Shell/Os.php"
click node_watchdog "https://github.com/sanchescom/php-wifi/blob/master/src/Watchdog/Watchdog.php"
click node_portal "https://github.com/sanchescom/php-wifi/blob/master/src/Provision/Portal.php"
click node_setup "https://github.com/sanchescom/php-wifi/blob/master/src/Provision/SetupPage.php"
click node_supervisor "https://github.com/sanchescom/php-wifi/blob/master/src/Provision/Supervisor.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_facade,node_values,node_collection,node_exceptions,node_user toneBlue
class node_factory,node_contract,node_nmcli,node_wpacli,node_macos,node_windows,node_parsers toneAmber
class node_shell,node_runner,node_os toneMint
class node_watchdog,node_portal,node_setup,node_supervisor toneRose
class node_system,node_phone toneIndigo
```

## Components

### Library API

- [WiFi CLI](https://github.com/sanchescom/php-wifi/blob/master/src/Cli/WiFiCli.php): `src/Cli/WiFiCli.php`
- [WiFi Facade](https://github.com/sanchescom/php-wifi/blob/master/src/WiFi.php): `src/WiFi.php`
- [Network Values](https://github.com/sanchescom/php-wifi/blob/master/src/Value/Network.php): `src/Value/Network.php`
- [Network Collection](https://github.com/sanchescom/php-wifi/blob/master/src/Value/NetworkCollection.php): `src/Value/NetworkCollection.php`
- [WiFi Exceptions](https://github.com/sanchescom/php-wifi/tree/master/src/Exception): `src/Exception`

### Platform Backends

- [Backend Selection](https://github.com/sanchescom/php-wifi/blob/master/src/Backend/BackendFactory.php): `src/Backend/BackendFactory.php`
- [Backend Contract](https://github.com/sanchescom/php-wifi/blob/master/src/Backend/Backend.php): `src/Backend/Backend.php`
- [NetworkManager](https://github.com/sanchescom/php-wifi/blob/master/src/Backend/NmcliBackend.php): `src/Backend/NmcliBackend.php`
- [wpa supplicant](https://github.com/sanchescom/php-wifi/blob/master/src/Backend/WpaCliBackend.php): `src/Backend/WpaCliBackend.php`
- [macOS Backend](https://github.com/sanchescom/php-wifi/blob/master/src/Backend/NetworksetupBackend.php): `src/Backend/NetworksetupBackend.php`
- [Windows Backend](https://github.com/sanchescom/php-wifi/blob/master/src/Backend/NetshBackend.php): `src/Backend/NetshBackend.php`
- [Output Parsers](https://github.com/sanchescom/php-wifi/tree/master/src/Parser): `src/Parser`

### Command Runtime

- [Command Model](https://github.com/sanchescom/php-wifi/blob/master/src/Shell/Command.php): `src/Shell/Command.php`
- [Command Runner](https://github.com/sanchescom/php-wifi/blob/master/src/Shell/ShellCommandRunner.php): `src/Shell/ShellCommandRunner.php`
- [OS Detection](https://github.com/sanchescom/php-wifi/blob/master/src/Shell/Os.php): `src/Shell/Os.php`

### Recovery And Setup

- [WiFi Watchdog](https://github.com/sanchescom/php-wifi/blob/master/src/Watchdog/Watchdog.php): `src/Watchdog/Watchdog.php`
- [Captive Portal](https://github.com/sanchescom/php-wifi/blob/master/src/Provision/Portal.php): `src/Provision/Portal.php`
- [Setup Page](https://github.com/sanchescom/php-wifi/blob/master/src/Provision/SetupPage.php): `src/Provision/SetupPage.php`
- [Provision Supervisor](https://github.com/sanchescom/php-wifi/blob/master/src/Provision/Supervisor.php): `src/Provision/Supervisor.php`

### Other components

- **User / App**
- **OS WiFi Tools**
- **Phone**

## Connections

- User / App → WiFi CLI: runs commands (evidence: `README.md`)
- User / App → WiFi Facade: calls API (evidence: `README.md`)
- WiFi CLI → WiFi Facade: uses API (evidence: `README.md`)
- WiFi Facade → Backend Selection: creates backend (evidence: `src/WiFi.php`)
- Backend Selection → Backend Contract: selects implementation (evidence: `README.md`)
- WiFi Facade → Backend Contract: delegates operations (evidence: `src/WiFi.php`)
- NetworkManager → Output Parsers: parses output (evidence: `src/Backend/NmcliBackend.php`)
- wpa supplicant → Output Parsers: parses output (evidence: `src/Backend/WpaCliBackend.php`)
- macOS Backend → Output Parsers: parses output
- Windows Backend → Output Parsers: parses output
- NetworkManager → Command Runner: runs commands (evidence: `src/Backend/NmcliBackend.php`)
- wpa supplicant → Command Runner: runs commands (evidence: `src/Backend/WpaCliBackend.php`)
- WiFi Facade → Network Collection: returns scan results (evidence: `src/WiFi.php`)
- Output Parsers → Network Values: builds networks (evidence: `src/Parser/Nmcli/ListParser.php`)
- Network Collection → Network Values: filters networks (evidence: `src/Value/NetworkCollection.php`)
- Command Runner → Command Model: executes command (evidence: `src/Shell/ShellCommandRunner.php`)
- Command Runner → OS WiFi Tools: invokes tools (evidence: `README.md`)
- WiFi Facade → WiFi Exceptions: raises capability errors (evidence: `src/WiFi.php`)
- WiFi Watchdog → WiFi Facade: reconnects / raises hotspot (evidence: `src/Watchdog/Watchdog.php`)
- WiFi Watchdog → Command Runner: checks stations (evidence: `src/Watchdog/Watchdog.php`)
- WiFi CLI → Provision Supervisor: starts provisioning (evidence: `src/Cli/WiFiCli.php`)
- Provision Supervisor → Captive Portal: coordinates setup
- Captive Portal → WiFi Facade: scans / joins / starts hotspot (evidence: `src/Provision/Portal.php`)
- Setup Page → Captive Portal: renders portal responses (evidence: `src/Provision/SetupPage.php`)
- Phone → Captive Portal: submits credentials (evidence: `README.md`)
