定制 madpilot78/freebox-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

madpilot78/freebox-php

最新稳定版本:1.3.1

Composer 安装命令:

composer require madpilot78/freebox-php

包简介

PHP library to access the FreeBox APIs

README 文档

README

Packagist Version Actions Status codecov

This is a small and simple PHP library to interface with Iliad FreeBox (IliadBox for the Italian market) provided broadband routers.

Install

Using composer:

composer require madpilot78/FreeBoxPHP

Requirements

This project works with PHP 8.3 and upper.

Library description

I'm writing this library for my own needs. It handles discovery and authentication and then exposes some router APIs via methods.

For a list of implemented methods look in src/Methods.

NOTE: Since I'm in Italy I have tested this only with my router, an IliadBox (Italian version), configured with self provided certificate. If you have a different setup and have problems, please contact me and maybe I can update the library to work with more setups.

NOTE

For documentation on each API specifics please check your OpenBox/IliadBox developer documentation, accessible through the WebUI.

How to use

There is a Configuration object that can be used to customize the library.

First one needs to register with the Box, for example:

use madpilot78\FreeBoxPHP\Configuration;
use madpilot78\FreeBoxPHP\Box;
use madpilot78\FreeBoxPHP\Enum\BoxType;

$config = new Configuration(
    hostname: 'box.example.org',
    boxType: BoxType::Iliad,
    certFile: null,
);

$box = new Box(configuration: $config);

$token = $box->discover()->register(quiet: false);

echo $token . PHP_EOL;

(check the FreeBox/IliadBox display to authorize the client)

Once the client has been authorized its permissions can be configured in the FreeBox/IliadBox UI.

With the token it is possible to access all the provided functionality.

For example to display IPv6 configuration:

use madpilot78\FreeBoxPHP\Configuration;
use madpilot78\FreeBoxPHP\Box;
use madpilot78\FreeBoxPHP\Enum\BoxType;

$config = new Configuration(
    hostname: 'box.example.org',
    boxType: BoxType::Iliad,
    certFile: null,
);

$box = new Box(authToken: '<token>', configuration: $config);

$ret = $box->discover()->connectionIPv6Configuration('get');

var_dump($ret);

(NOTE: discover() needs to be called only once per instance, results are cached in the instance)

The IPv6 firewall can be turned on with (this API will also return the new configuration):

$ret = $box->connectionIPv6Configuration('update', ['ipv6_firewall' => true]);

var_dump($ret);

APIs requiring an ID take it as an argument, for example to fetch an existing redirect:

$ret = $box->fwRedir('get', 1);

var_dump($ret);

And a disabled redirect can be modified (for example enabled) like this:

$ret = $box->fwRedir('update', 1, ['enabled' => true]);

var_dump($ret);

Implemented APIs

  • Discover
  • Register
  • Login/Logout (login performed automatically if needed)
  • Language (changing the language may not work, I suspect this is a restriction on my IliadBox)
  • ConnectionConfiguration
  • ConnectionIPv6Configuration
  • ConnectionStatus (r/o)
  • LanBrowserInterface (r/o)
  • LAN WOL

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2024-07-02