PHP WiFi is cross-platform php library based on integrated in OS utilities
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Require this package, with Composer, in the root directory of your project.
$ composer require sanchescom/php-wifi
<?php
include __DIR__ . '/vendor/autoload.php';
use Sanchescom\WiFi\WiFi;
class Example
{
public $device;
/**
* @throws Exception
*/
public function getAllNetworks()
{
$networks = WiFi::scan()->getAll();
foreach ($networks as $network) {
echo $network . "\n";
}
}
/**
* @param $ssid
* @param $password
*/
public function connect($ssid, $password)
{
try {
WiFi::scan()->getBySsid($ssid)->connect($password, $this->device);
} catch (Exception $exception) {
echo $exception->getMessage();
}
}
/**
* @throws Exception
*/
public function disconnect()
{
$networks = WiFi::scan()->getConnected();
foreach ($networks as $network) {
$network->disconnect($this->device);
}
}
}
$example = new Example();
try {
$example->device = 'en1';
$example->getAllNetworks();
$example->connect('Redmi', '12345');
$example->disconnect();
} catch (Exception $e) {
//
}
$ ./vendor/bin/wifi list
$ ./vendor/bin/wifi list --connected
$ ./vendor/bin/wifi connect --bssid=4c:49:e3:f5:35:17 --password=12345 --device=en1
$ ./vendor/bin/wifi disconnect --bssid=4c:49:e3:f5:35:17 --device=en1
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Efimov Aleksandr - Initial work - Sanchescom
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details
- Linux
- MacOS
- Windows