datasift/netifaces

此包已被废弃且不再维护。未建议替代包。
关于此包的最新版本(0.1.0)没有可用的许可证信息。

0.1.0 2013-08-09 17:13 UTC

This package is not auto-updated.

Last update: 2023-12-05 01:04:05 UTC


README

安装

将以下内容添加到您的 composer.json 文件中

{
    "requires": {
        "datasift/netifaces": "*"
    }
}

用法

我们目前支持两种方法,listAdapters()getIpAddress()

require __DIR__.'/../vendor/autoload.php';

// To get information about our network adapters, we need to know about two things
// 1. The OS that we're on
$os = Datasift\Os::getOs();
// 2. We need a parser for the ifconfig output
$parser = Datasift\IfconfigParser::fromDistributions($os->getPossibleClassNames());

// Next, we create a new netifaces instance, passing in our OS and Parser
$netifaces = new Datasift\netifaces($os, $parser);

// Then we can list the available adapters
var_dump($netifaces->listAdapters());

// Or get the IP address if a specific adapter
var_dump($netifaces->getIpAddress("eth0"));