定制 srhmster/php-dbus 二次开发

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

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

srhmster/php-dbus

Composer 安装命令:

composer require srhmster/php-dbus

包简介

PHP library for interact with DBus

README 文档

README

PHP library for interact with DBus. By default, the console utility busctl is used.

Basic usage

Composer

This library is designed for use with the composer PHP dependency manager. Simply add the srhmster/php-dbus package to get started:

composer require srhmster/php-dbus

Manually

If you don't have composer available, then simply download the code

git clone https://github.com/srhmster/php-dbus vendor/srhmster/php-dbus

and include autoload.php

<?php

require_once __DIR__ . '/vendor/srhmster/php-dbus/autoload.php';

Examples

Files with examples of using the library can be found in the examples directory

Available methods

__construct($service, Marshaller $marshaller = null, Command $command = null)

Construct new Dbus service object

Parameters:

  • string $service - Dbus service name
  • Marshaller|null $marshaller - Object of data converter, BusctlMarshaller by default
  • Command|null $command - Object of console command, BusctlCommand by default

call($objectPath, $interface, $method, $properties = null, $useSudo = false, $options = [])

Invoke a method and show the response

Parameters:

  • string $objectPath - Dbus object path
  • string $interface - Dbus interface name
  • string $method - Method name
  • mixed|null $properties - Properties value, null by default
  • bool $useSudo - Use sudo flag, false by default
  • array $options - Command options, empty array by default

Response: array|string|int|float|bool|null

emit($objectPath, $interface, $signal, $value = null, $useSudo = false, $options = [])

Emit a signal

Parameters:

  • string $objectPath - Dbus object path
  • string $interface - Dbus interface name
  • string $signal - Signal name
  • mixed|null $value - Signal value, null by default
  • bool $useSudo - Use sudo flag, false by default
  • array $options - Command options, empty array by default

Response: void

getProperty($objectPath, $interface, $name, $useSudo = false, $options = [])

Retrieve the current value of object property

Parameters:

  • string $objectPath - Dbus object path
  • string $interface - Dbus interface name
  • string $name - Property name
  • bool $useSudo - Use sudo flag, false by default
  • array $options - Command options, empty array by default

Response: array|string|int|float|bool|null

setProperty($objectPath, $interface, $name, $value = null, $useSudo = false, $options = [])

Set the current value of an object property

Parameters:

  • string $objectPath - Dbus object path
  • string $interface - Dbus interface name
  • string $name - Property name
  • mixed|null $value - Property value, null by default
  • bool $useSudo - Use sudo flag, false by default
  • array $options - Command options, empty array by default

Response: void

Command options format

If the option does not require a value, then specify only its name

$options = [
    'option_name_1',
    'option_name_2',
];

otherwise specify an array

$options = [
    ['option_name_1', 'option_value_1'],
    ['option_name_2', 'option_value_2'],
];

BusctlDataObject

This is a set of classes for convenient work with data in PHP. The BusctlMarshaller can convert this data into the correct Dbus format. Use the base class BusctlDataObject static methods described below to create a data object with the desired data type.

Available methods

::s($value = null)

Create string data object. Base data type

Parameters:

  • string|null $value - Data object value, null by default

Response: StringDataObject

::o($value = null)

Create object path data object. Base data type

Parameters:

  • string|null $value - Data object value, null by default

Response: ObjectPathDataObject

::b($value = null)

Create boolean data object. Base data type

Parameters:

  • bool|null $value - Data object value, null by default

Response: BooleanDataObject

::y($value = null)

Create byte data object. Base data type

Parameters:

  • int|null $value - Data object value, null by default

Response: NumericDataObject

::n($value = null)

Create int16 data object. Base data type

Parameters:

  • int|null $value - Data object value, null by default

Response: NumericDataObject

::q($value = null)

Create uint16 data object. Base data type

Parameters:

  • int|null $value - Data object value, null by default

Response: NumericDataObject

::i($value = null)

Create int32 data object. Base data type

Parameters:

  • int|null $value - Data object value, null by default

Response: NumericDataObject

::u($value = null)

Create uint32 data object. Base data type

Parameters:

  • int|null $value - Data object value, null by default

Response: NumericDataObject

::x($value = null)

Create int64 data object. Base data type

Parameters:

  • int|null $value - Data object value, null by default

Response: NumericDataObject

::t($value = null)

Create uint64 data object. Base data type

Parameters:

  • int|null $value - Data object value, null by default

Response: NumericDataObject

::d($value = null)

Create double data object. Base data type

Parameters:

  • float|null $value - Data object value, null by default

Response: NumericDataObject

::v(BusctlDataObject $value)

Create variant data object. Container data type

Parameters:

  • BusctlDataObject $value - Any data object other than a VariantDataObject

Response: VariantDataObject

::r($value)

Create struct data object. Container data type

Parameters:

  • BusctlDataObject|BusctlDataObject[] $value

Response: StructDataObject

::a($value)

Create array data object. Container data type

Parameters:

  • BusctlDataObject[] $value

Response: ArrayDataObject

::e($value)

Create map data object. Container data type

Parameters:

  • BusctlDataObject[][] $value - Each element of the array must be in the format ['key' => BusctlDataObject, 'value' => BusctlDataObject]. Key value can only be a base data type.

Response: MapDataObject

srhmster/php-dbus 适用场景与选型建议

srhmster/php-dbus 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 39 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 09 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「dbus」 「busctl」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 srhmster/php-dbus 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 srhmster/php-dbus 我们能提供哪些服务?
定制开发 / 二次开发

基于 srhmster/php-dbus 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-04