https://github.com/tomnomnom/phpwol
Wake On LAN for PHP
https://github.com/tomnomnom/phpwol
Last synced: about 1 year ago
JSON representation
Wake On LAN for PHP
- Host: GitHub
- URL: https://github.com/tomnomnom/phpwol
- Owner: tomnomnom
- License: mit
- Created: 2013-02-17T22:30:09.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2017-03-21T23:25:34.000Z (about 9 years ago)
- Last Synced: 2025-03-25T01:07:04.059Z (about 1 year ago)
- Language: PHP
- Size: 11.7 KB
- Stars: 11
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.mkd
- Changelog: CHANGELOG.mkd
- License: LICENSE
Awesome Lists containing this project
README
# Phpwol
Send Wake On LAN packets with PHP.
## Contents
* [Installation](#installation)
* [Usage](#usage)
* [Testing](#testing)
## Installation
Phpwol is available on [Packagist](https://packagist.org/packages/tomnomnom/phpwol) so you can
install it using [Composer](http://getcomposer.org/). Just specify it as a dependency in your
`composer.json`:
```json
{
"require": {
"tomnomnom/phpwol": "0.1.0"
}
}
```
Then run `composer install`:
```
▶ composer install
Loading composer repositories with package information
Installing dependencies
- Installing tomnomnom/phpwol (0.1.0)
Downloading: 100%
Writing lock file
Generating autoload files
```
Once installed you can use the Composer autoloader instead of the one provided in `./Phpwol/Init.php`:
```php
magicPacket();
```
## Usage
A `\Phpwol\MagicPacket` object is used to send a WOL packet. Such an object is availble via the `\Phpwol\Factory::magicPacket()` method.
```php
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";
}
```
```
▶ php ./Examples/Basic.php
Worked
```
If you don't know what the broadcast IP is and don't know how to work it out, you can just specify the IP and subnet mask
and everything will be worked out for you.
```php
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/UnknownBroadcast.php
Worked
```
## Requirements
* Linux of some description
* PHP 5.3 or newer
## Testing
You can run the tests by running:
```
▶ phpunit
```
The repo is hooked up to Travis CI. You can see the state of the master branch and the
build history on the [Phpwol Travis CI page](https://travis-ci.org/tomnomnom/phpwol).
The full test suite runs under PHP 5.3 and PHP 5.4.