aso824 / octoprint-php-api
用PHP编写的OctoPrint API客户端
v0.1.2
2020-09-26 22:30 UTC
Requires
- php: ^7.4
- ext-json: *
- nyholm/psr7: ^1.3
- phpdocumentor/reflection-docblock: ^5.0
- psr/http-client: ^1.0
- psr/http-message: ^1.0
- symfony/property-access: ^5.0
- symfony/serializer: ^5.0
Requires (Dev)
- phpunit/phpunit: ^9.3
This package is auto-updated.
Last update: 2024-09-27 08:03:25 UTC
README
API包装器,允许在您的PHP应用程序中轻松使用OctoPrint REST API。
请注意,该库目前处于WIP状态。
要求
- PHP ^7.4
- Symfony Serializer ^5.0
- 任何PSR-18兼容的HTTP客户端(考虑使用HTTPlug)
- OctoPrint ^1.4
安装
composer require aso824/octoprint-php-api
用法
以下简单示例假设您正在使用HTTPlug并且有兼容的HTTP客户端。
use Http\Discovery\HttpClientDiscovery; use aso824\OctoPrintPHP\Client; use aso824\OctoPrintPHP\Configuration; $httpClient = HttpClientDiscovery::find(); $configuration = new Configuration('http://octoprint.local', 'your-api-key'); $octoClient = new Client($configuration, $httpClient); var_dump($octoClient->getVersion()->getServer()); // "1.4.2" $file = $octoClient->files->getFile('test.gcode'); var_dump($file->getGcodeAnalysis()->getEstimatedPrintTime()); // 10120 (seconds)
有关可用操作的列表,请访问OctoPrint REST API文档。
目前实现端点
贡献
欢迎所有拉取请求。请遵循现有文件中的相同约定。
许可证
此库受MIT许可证约束。