The purpose of this fork is to implement OData v2 support. While basic requests are functional, the adaptation is still a work in progress and not ready for general production application.
The rest of the README below is, for now, largely unchanged from the original repo.
A fluent library for calling OData REST services inspired by and based on the Laravel Query Builder.
You can install the PHP SDK with Composer.
composer require saintsystems/odata-client
The following is an example that shows how to call an OData service.
<?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();Run vendor/bin/phpunit from the base directory.
View or log issues on the Issues tab in the repo.
Copyright (c) Saint Systems, LLC. All Rights Reserved. Licensed under the MIT license.