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 nameMarshaller|null $marshaller- Object of data converter,BusctlMarshallerby defaultCommand|null $command- Object of console command,BusctlCommandby default
call($objectPath, $interface, $method, $properties = null, $useSudo = false, $options = [])
Invoke a method and show the response
Parameters:
string $objectPath- Dbus object pathstring $interface- Dbus interface namestring $method- Method namemixed|null $properties- Properties value,nullby defaultbool $useSudo- Use sudo flag,falseby defaultarray $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 pathstring $interface- Dbus interface namestring $signal- Signal namemixed|null $value- Signal value,nullby defaultbool $useSudo- Use sudo flag,falseby defaultarray $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 pathstring $interface- Dbus interface namestring $name- Property namebool $useSudo- Use sudo flag,falseby defaultarray $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 pathstring $interface- Dbus interface namestring $name- Property namemixed|null $value- Property value,nullby defaultbool $useSudo- Use sudo flag,falseby defaultarray $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,nullby default
Response: StringDataObject
::o($value = null)
Create object path data object. Base data type
Parameters:
string|null$value - Data object value,nullby default
Response: ObjectPathDataObject
::b($value = null)
Create boolean data object. Base data type
Parameters:
bool|null$value - Data object value,nullby default
Response: BooleanDataObject
::y($value = null)
Create byte data object. Base data type
Parameters:
int|null$value - Data object value,nullby default
Response: NumericDataObject
::n($value = null)
Create int16 data object. Base data type
Parameters:
int|null$value - Data object value,nullby default
Response: NumericDataObject
::q($value = null)
Create uint16 data object. Base data type
Parameters:
int|null$value - Data object value,nullby default
Response: NumericDataObject
::i($value = null)
Create int32 data object. Base data type
Parameters:
int|null$value - Data object value,nullby default
Response: NumericDataObject
::u($value = null)
Create uint32 data object. Base data type
Parameters:
int|null$value - Data object value,nullby default
Response: NumericDataObject
::x($value = null)
Create int64 data object. Base data type
Parameters:
int|null$value - Data object value,nullby default
Response: NumericDataObject
::t($value = null)
Create uint64 data object. Base data type
Parameters:
int|null$value - Data object value,nullby default
Response: NumericDataObject
::d($value = null)
Create double data object. Base data type
Parameters:
float|null$value - Data object value,nullby 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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 srhmster/php-dbus 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
DBUS bindings for PHP language
Alfabank REST API integration
Zero-dependency raw PHP DNS resolver, domain-ownership verification, and intoDNS/MxToolbox-style diagnostics. Queries authoritative nameservers directly over sockets — never trusts the recursive cache for ownership checks.
D-Bus Notification Library for Derick Rethans D-Bus PHP extension
A lightweight plain-PHP framework for database-backed CRUD APIs.
bughq error tracking - PHP SDK
统计信息
- 总下载量: 39
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-04