haydentapp / odata-client
Saint Systems OData Client for PHP
1.0.3
2022-11-09 10:10 UTC
Requires
- php: ^8.0
- guzzlehttp/guzzle: ^6.0 || ^7.0
- illuminate/support: ^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- nesbot/carbon: ^2.0
Requires (Dev)
- phpunit/phpunit: ^9.0
README
一个灵感来源于并基于 Laravel Query Builder 的调用 OData REST 服务的流畅库。
注意
这是一个基于 SaintSystems 提供的 OData 客户端的分支,已更新以使其与 Drupal CMS 兼容。
安装 SDK
您可以使用 Composer 安装 PHP SDK。
composer require haydentapp/odata-client
调用 OData 服务
以下是一个展示如何调用 OData 服务的示例。
<?php
require_once __DIR__ . '/vendor/autoload.php';
use SaintSystems\OData\ODataClient;
class UsageExample
{
public function __construct()
{
$odataServiceUrl = 'https://services.odata.org/V4/TripPinService';
$odataClient = new ODataClient($odataServiceUrl);
// Retrieve all entities from the "People" Entity Set
$people = $odataClient->from('People')->get();
// Or retrieve a specific entity by the Entity ID/Key
try {
$person = $odataClient->from('People')->find('russellwhyte');
echo "Hello, I am $person->FirstName ";
} catch (Exception $e) {
echo $e->getMessage();
}
// Want to only select a few properties/columns?
$people = $odataClient->from('People')->select('FirstName','LastName')->get();
}
}
$example = new UsageExample();
开发
运行测试
从基本目录运行 `
vendor/bin/phpunit`
。
文档和资源
问题
在仓库的 问题 标签中查看或记录问题。
版权和许可
版权(c)Saint Systems, LLC。版权所有。在 MIT 许可 下许可。