tomnomnom/phpwol 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tomnomnom/phpwol

最新稳定版本:0.1.1

Composer 安装命令:

composer require tomnomnom/phpwol

包简介

Wake On LAN for PHP

README 文档

README

Send Wake On LAN packets with PHP.

Contents

Installation

Phpwol is available on Packagist so you can install it using Composer. Just specify it as a dependency in your composer.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
require __DIR__.'/vendor/autoload.php';

$f = new \Phpwol\Factory();
$m = $f->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
// ./Examples/Basic.php
require __DIR__.'/../Phpwol/Init.php';

$f = new \Phpwol\Factory();
$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";
}
▶ 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
// ./Examples/UnknownBroadcast.php
require __DIR__.'/../Phpwol/Init.php';

$f = new \Phpwol\Factory();
$magicPacket = $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/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. The full test suite runs under PHP 5.3 and PHP 5.4.

统计信息

  • 总下载量: 4.34k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-02-18