Download the PHP package sanchescom/php-wifi without Composer
On this page you can find all versions of the php package sanchescom/php-wifi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sanchescom/php-wifi
More information about sanchescom/php-wifi
Files in sanchescom/php-wifi
Package php-wifi
Short Description PHP library for working with wifi network
License GPL-3.0
Informations about the package php-wifi
PHP WiFi
A modern, cross-platform PHP library for managing WiFi networks. Built with PHP 8.1+ and fully typed for better IDE support and type safety.
Features
- Cross-platform support: Works on Linux, macOS, and Windows
- Modern PHP 8.1+: Fully typed properties, strict types, and modern syntax
- Rich API: Scan networks, connect/disconnect, filter by various parameters
- Powerful filtering: Filter by security type, signal strength, frequency band, and more
- Collection-based: Fluent interface with Laravel-style collections
- Type-safe: Full type hints and strict typing throughout
Requirements
- PHP 8.1, 8.2, or 8.3
- Operating System: Linux, macOS (Darwin), or Windows
- Appropriate system utilities (networksetup on macOS, nmcli on Linux, netsh on Windows)
Installing
Require this package, with Composer, in the root directory of your project.
Basic Usage
Scanning for Networks
Connecting and Disconnecting
Advanced Usage
Filtering Networks
Finding Specific Networks
Sorting Networks
Working with Network Properties
Static Helper Methods
CLI Usage
The library includes a command-line interface for managing WiFi networks directly from the terminal.
List all available networks
List only connected networks
Connect to a network
Disconnect from a network
API Reference
WiFi Class (Static Methods)
| Method | Return Type | Description |
|---|---|---|
WiFi::scan() |
Collection |
Scan for all available networks |
WiFi::getConnected() |
AbstractNetwork[] |
Get all connected networks |
WiFi::getStrongestNetwork() |
AbstractNetwork |
Get the strongest available network |
WiFi::get24GhzNetworks() |
Collection |
Get all 2.4GHz networks |
WiFi::get5GhzNetworks() |
Collection |
Get all 5GHz networks |
WiFi::getNetworksBySecurity(string $type) |
Collection |
Get networks by security type |
Collection Methods
| Method | Return Type | Description |
|---|---|---|
getAll() |
AbstractNetwork[] |
Get all networks as array |
getBySsid(string $ssid) |
AbstractNetwork |
Find network by SSID |
getByBssid(string $bssid) |
AbstractNetwork |
Find network by BSSID (MAC) |
getConnected() |
AbstractNetwork[] |
Get connected networks |
getBySecurity(string $type) |
Collection |
Filter by security type |
getByMinSignalStrength(float $dbm) |
Collection |
Filter by minimum signal strength |
getByChannel(int $channel) |
Collection |
Filter by channel |
get24GhzNetworks() |
Collection |
Get 2.4GHz networks |
get5GhzNetworks() |
Collection |
Get 5GHz networks |
sortBySignalStrength() |
Collection |
Sort by signal strength |
getStrongest() |
AbstractNetwork |
Get strongest network |
Network Properties
| Property | Type | Description |
|---|---|---|
$ssid |
string |
Network name |
$bssid |
string |
MAC address |
$channel |
int |
WiFi channel |
$frequency |
int |
Frequency in MHz |
$quality |
float |
Signal quality percentage |
$dbm |
float |
Signal strength in dBm |
$security |
string |
Security type |
$securityFlags |
string |
Security flags |
$connected |
bool |
Connection status |
Network Methods
| Method | Parameters | Description |
|---|---|---|
connect() |
string $password, string $device |
Connect to the network |
disconnect() |
string $device |
Disconnect from the network |
getSecurityType() |
- | Get security type (WPA2/WPA/WEP) |
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Efimov Aleksandr - Initial work - Sanchescom
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Platform Support
Linux
- Requires
nmcli(NetworkManager command-line interface) - Default device:
wlan0orwlan1
macOS
- Scanning: Uses
system_profiler SPAirPortDataType(official Apple tool, no deprecation warnings) - Backward Compatibility: Automatically supports old
airportformat if needed - Connection management: Requires
networksetup(built-in) - Default device:
en0oren1
Windows
- Requires
netsh(built-in) - Automatically detects WiFi interface
What's New in v2.0
- PHP 8.1+ Support: Fully refactored with typed properties and modern PHP syntax
- Updated Dependencies: All dependencies updated to latest versions
- Extended Functionality: New filtering and sorting methods
- Better Type Safety: Full type hints throughout the codebase
- Improved Collections: Switched to
illuminate/collectionswith fluent interface - macOS Improvements:
- Migrated to official
system_profilertool (no more deprecation warnings!) - Dual-format parser supports both new and legacy formats
- Migrated to official
- New Features:
- Filter networks by frequency band (2.4GHz / 5GHz)
- Filter by signal strength
- Find strongest network
- Sort networks by various criteria
- Enhanced security filtering
Upgrading from v1.x
The main breaking changes:
- Minimum PHP version is now 8.1 (was 7.2)
- Collection methods now have proper return types
tightenco/collectreplaced withilluminate/collections
Most of the existing API remains compatible. New methods are additive.
Testing
Code Style
Platform-Specific Notes
Device Names
- macOS: Use
en0,en1, etc. Find your device withnetworksetup -listallhardwareports - Linux: Use
wlan0,wlan1, etc. Find your device withip link show - Windows: Device is auto-detected by the library
All versions of php-wifi with dependencies
splitbrain/php-cli Version ^1.3
illuminate/collections Version ^11.46
phplucidframe/console-table Version ^1.3