PHP code example of tomnomnom / phpwol

1. Go to this page and download the library: Download tomnomnom/phpwol library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tomnomnom / phpwol example snippets



 new \Phpwol\Factory();
$m = $f->magicPacket();


// ./Examples/Basic.php
$magicPacket = $f->magicPacket();

$macAddress = '50:46:5C:53:94:25';
$broadcastIP = '192.168.1.255';

$result = $magicPacket->send($macAddress, $broadcastIP);

if ($result){
  echo "Worked\n";
} else {
  echo "Failed\n";
}



// ./Examples/UnknownBroadcast.php
t = $f->magicPacket();

$macAddress = '50:46:5C:53:94:25';
$ip = '192.168.1.10';
$subnet = '255.255.255.0';

$result = $magicPacket->send($macAddress, $ip, $subnet);

if ($result){
  echo "Worked\n";
} else {
  echo "Failed\n";
}


▶ php ./Examples/Basic.php
Worked

▶ php ./Examples/UnknownBroadcast.php
Worked