PHPackages                             saintsystems/odata-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. saintsystems/odata-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

saintsystems/odata-client
=========================

Saint Systems OData Client for PHP

1.0.1(8mo ago)160549.9k↓44%112[6 issues](https://github.com/saintsystems/odata-client-php/issues)[3 PRs](https://github.com/saintsystems/odata-client-php/pulls)2MITPHPPHP ^7.4 || ^8.0 || ^8.1 || ^8.2 || ^8.3 || ^8.4CI passing

Since Aug 24Pushed 7mo ago12 watchersCompare

[ Source](https://github.com/saintsystems/odata-client-php)[ Packagist](https://packagist.org/packages/saintsystems/odata-client)[ Docs](https://github.com/saintsystems/odata-client-php)[ RSS](/packages/saintsystems-odata-client/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (8)Versions (36)Used By (2)

Get started with the OData Client for PHP
=========================================

[](#get-started-with-the-odata-client-for-php)

A fluent library for calling OData REST services inspired by and based on the [Laravel Query Builder](https://laravel.com/docs/5.4/queries).

[![Build Status](https://github.com/saintsystems/odata-client-php/actions/workflows/ci.yml/badge.svg)](https://github.com/saintsystems/odata-client-php/actions/workflows/ci.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/4244e6fd7c2b68fb31aa61ad3c8cdc7b94afa3e70e6427cdb4c12d1b3032d235/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7361696e7473797374656d732f6f646174612d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/saintsystems/odata-client)[![Total Downloads](https://camo.githubusercontent.com/138a70307d93b1f5dea49103d0cd74f398fa4ea0f7bafa737b5976d242390d91/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7361696e7473797374656d732f6f646174612d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/saintsystems/odata-client)

For WordPress users, please see our [Gravity Forms Dynamics 365 Add-On](https://www.saintsystems.com/products/gravity-forms-dynamics-crm-add-on/).

Install the SDK
---------------

[](#install-the-sdk)

You can install the PHP SDK with Composer.

```
composer require saintsystems/odata-client

```

### HTTP Provider Configuration

[](#http-provider-configuration)

Starting from version 0.10.0, the OData Client requires an HTTP provider to be explicitly set. This allows you to use any HTTP client implementation that suits your needs.

As of version 1.0.0, we will be using [semver](https://semver.org/).

#### Using Guzzle (recommended for most users)

[](#using-guzzle-recommended-for-most-users)

First, install Guzzle:

```
composer require guzzlehttp/guzzle
```

Then configure the OData client:

```
use SaintSystems\OData\ODataClient;
use SaintSystems\OData\GuzzleHttpProvider;

$httpProvider = new GuzzleHttpProvider();
$odataClient = new ODataClient($odataServiceUrl, null, $httpProvider);
```

#### Using PSR-17/PSR-18 implementations

[](#using-psr-17psr-18-implementations)

You can also use any PSR-17/PSR-18 compatible HTTP client:

```
use SaintSystems\OData\ODataClient;
use SaintSystems\OData\Psr17HttpProvider;

// Example using Symfony HTTP Client with Nyholm PSR-7
$httpClient = new \Symfony\Component\HttpClient\Psr18Client();
$requestFactory = new \Nyholm\Psr7\Factory\Psr17Factory();
$streamFactory = new \Nyholm\Psr7\Factory\Psr17Factory();

$httpProvider = new Psr17HttpProvider($httpClient, $requestFactory, $streamFactory);
$odataClient = new ODataClient($odataServiceUrl, null, $httpProvider);
```

### Call an OData Service

[](#call-an-odata-service)

The following is an example that shows how to call an OData service.

```
