PHPackages                             themost/phpclient - 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. [Framework](/categories/framework)
4. /
5. themost/phpclient

ActiveLibrary[Framework](/categories/framework)

themost/phpclient
=================

MOST Web Framework PHP Client Library

v1.0.0.x-dev(11y ago)1411BSD-3-ClausePHP

Since Mar 3Pushed 6y ago2 watchersCompare

[ Source](https://github.com/kbarbounakis/most-phpclient)[ Packagist](https://packagist.org/packages/themost/phpclient)[ Docs](http://themost.io/)[ RSS](/packages/themost-phpclient/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

most-phpclient
==============

[](#most-phpclient)

[MOST Web Framework](https://github.com/kbarbounakis/most-web) PHP Client Library

[![MOST Web Framework Logo](https://camo.githubusercontent.com/538435d10e5dbf0811e64767cfa2ddc537caf80b4bdad49df697957b78f35dd9/68747470733a2f2f7777772e7468656d6f73742e696f2f6173736574732f696d616765732f6d6f73745f6c6f676f5f73775f3234302e706e67)](https://camo.githubusercontent.com/538435d10e5dbf0811e64767cfa2ddc537caf80b4bdad49df697957b78f35dd9/68747470733a2f2f7777772e7468656d6f73742e696f2f6173736574732f696d616765732f6d6f73745f6c6f676f5f73775f3234302e706e67)

### Usage

[](#usage)

If you don't have a MOST Web Framework application clone [MOST Web Framework OMS Demo](https://github.com/kbarbounakis/most-web-oms-demo) application and follow the installation instructions.

Create a new PHP project and use MOST Web Framework PHP Client to communicate with this application.

### Authentication

[](#authentication)

Use basic authentication:

```
context->authenticate("alexis.rees@example.com","user");

```

Use cookie based authentication:

```
//get cookie from request
context.getService().setCookie($response->getCookies());

```

### ClientDataContext Class

[](#clientdatacontext-class)

#### model(name)

[](#modelname)

Gets an instance of ClientDataModel class based on the given name.

```
$result = $context->model("Order")
    ->where("orderStatus")->equal(1)
    ->getItems();
var_dump($result);

```

#### getService()

[](#getservice)

Gets the instance of ClientDataService associated with this data context.

```
print $context->getService()->getBase();

```

#### setService(service)

[](#setserviceservice)

Associates the given ClientDataService instance with this data context.

```
$context->setService(new MyDataService("http://data.example.com"));

```

### ClientDataModel Class

[](#clientdatamodel-class)

#### getName()

[](#getname)

Gets a string which represents the name of this data model.

#### getService()

[](#getservice-1)

Gets the instance of ClientDataService associated with this data model.

#### remove(obj)

[](#removeobj)

Removes the given item or array of items.

```
$order = new stdClass();
$order->id = 23;
$context->model("Order")->remove($order);
var_dump($order);

```

#### save(obj)

[](#saveobj)

Creates or updates the given item or array of items.

```
$result = $context->model("Order")
    ->where("id")
    ->equal("23")
    ->getItem();
$result->orderStatus = 3;
$context->model("Order")->save($result);
var_dump($result);

```

#### getSchema()

[](#getschema)

Returns the JSON schema of this data model.

```
$context = $this->getContext();
$schema = $context->model("Group")->getSchema();
var_dump($schema);

```

#### select(...attr)

[](#selectattr)

Initializes and returns an instance of ClientDataQueryable class by selecting an attribute or a collection of attributes.

```
$result = $context->model("User")
    ->where("name")
    ->equal("alexis.rees@example.com")
    ->select("id","name","description")
    ->first();
var_dump($result) ;

```

#### skip(num)

[](#skipnum)

Initializes and returns an instance of ClientDataQueryable class by specifying the number of records to be skipped.

```
$context = $this->getContext();
$result = $context->model("Order")
    ->skip(10)
    ->take(10)
    ->getItems();
var_dump($result);

```

#### take(num)

[](#takenum)

Initializes and returns an instance of ClientDataQueryable class by specifying the number of records to be taken.

```
$context = $this->getContext();
$result = $context->model("Order")
    ->take(10)
    ->getItems();
var_dump($result);

```

#### where(attr)

[](#whereattr)

Initializes a comparison expression by using the given attribute as left operand and returns an instance of ClientDataQueryable class.

```
$context = $this->getContext();
$result = $context->model("Order")
    ->where("orderedItem/category")->equal("Laptops")
    ->take(10)
    ->getItems();
var_dump($result);

```

### ClientDataQueryable Class

[](#clientdataqueryable-class)

ClientDataQueryable class enables developers to perform simple and extended queries against data models. The ClienDataQueryable class follows [DataQueryable](https://docs.themost.io/most-data/DataQueryable.html)which is introduced by [MOST Web Framework ORM server-side module](https://github.com/kbarbounakis/most-data).

#### Logical Operators

[](#logical-operators)

Either (Or):

```
$result = $context->model("Product")
    ->where("category")->equal("Desktops")
    ->either("category")->equal("Laptops")
    ->orderBy("price")
    ->take(5)
    ->getItems();
var_dump($result);

```

Also (And):

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("category")->equal("Laptops")
    ->also("price")->between(200,750)
    ->orderBy("price")
    ->take(5)
    ->getItems();
var_dump($result);

```

#### Comparison Operators

[](#comparison-operators)

Equal:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("category")
    ->equal("Laptops")
    ->orderBy("price")
    ->getItems();
var_dump($result);

```

Not equal:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("category")
    ->notEqual("Laptops")
    ->also("category")
    ->notEqual("Desktops")
    ->orderBy("price")
    ->getItems();
var_dump($result);

```

Greater than:

```
$context = $this->getContext();
$result = $context->model("Order")
    ->where("orderedItem/price")->greaterThan(968)
    ->also("orderedItem/category")->equal("Laptops")
    ->also("orderStatus/alternateName")->notEqual("OrderCancelled")
    ->select("id",
        "orderStatus/name as orderStatusName",
        "customer/description as customerDescription",
        "orderedItem")
    ->orderByDescending("orderDate")
    ->take(10)
    ->getItems();
var_dump($result);

```

Greater or equal:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("price")->greaterOrEqual(1395.9)
    ->orderByDescending("price")
    ->take(10)
    ->getItems();
var_dump($result);

```

Lower than:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("price")->lowerThan(263.56)
    ->orderBy("price")
    ->take(10)
    ->getItems();
var_dump($result);

```

Lower or equal:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("price")->lowerOrEqual(263.56)
    ->also("price")->greaterOrEqual(224.52)
    ->orderBy("price")
    ->take(5)
    ->getItems();
var_dump($result);

```

Contains:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("name")->contains("Book")
    ->also("category")->equal("Laptops")
    ->orderBy("price")
    ->take(5)
    ->getItems();
var_dump($result);

```

Between:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("category")->equal("Laptops")
    ->either("category")->equal("Desktops")
    ->andAlso("price")->between(200,750)
    ->orderBy("price")
    ->take(5)
    ->getItems();
var_dump($result);

```

#### Aggregate Functions

[](#aggregate-functions)

Count:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->select("category", "count(id) as total")
    ->groupBy("category")
    ->orderByDescending("count(id)")
    ->getItems();
var_dump($result);

```

Min:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->select("category", "min(price) as minimumPrice")
    ->where("category")->equal("Laptops")
    ->either("category")->equal("Desktops")
    ->groupBy("category")
    ->orderByDescending("min(price)")
    ->getItems();
var_dump($result);

```

Max:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->select("category", "max(price) as maximumPrice")
    ->where("category")->equal("Laptops")
    ->getItem();
var_dump($result);

```

### String Functions:

[](#string-functions)

Index Of:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("name")->indexOf("Intel")
    ->greaterOrEqual(0)
    ->getItems();
var_dump($result);

```

Substring:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("name")->substr(6,4)
    ->equal("Core")
    ->getItems();
var_dump($result);

```

Starts with:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("name")->startsWith("Intel Core")
    ->equal(true)
    ->getItems();
var_dump($result);

```

Ends with:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("name")->endsWith("Edition")
    ->equal(true)
    ->getItems();
var_dump($result);

```

Lower case:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("category")->toLowerCase()
    ->equal("laptops")
    ->getItems();
var_dump($result);

```

Upper case:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("category")->toUpperCase()
    ->equal("LAPTOPS")
    ->getItems();
var_dump($result);

```

#### Date Functions:

[](#date-functions)

Date:

```
$context = $this->getContext();
$result = $context->model("Order")
    ->where("orderDate")->getDate()
    ->equal("2015-04-18")
    ->getItems();
var_dump($result);

```

Month:

```
$context = $this->getContext();
$result = $context->model("Order")
    ->where("orderDate")->getMonth()
    ->equal(4)
    ->getItems();
var_dump($result);

```

Day:

```
$context = $this->getContext();
$result = $context->model("Order")
    ->where("orderDate")->getMonth()->equal(4)
    ->also("orderDate")->getDay()->lowerThan(15)
    ->getItems();
var_dump($result);

```

Year:

```
$context = $this->getContext();
$result = $context->model("Order")
    ->where("orderDate")->getMonth()->equal(5)
    ->also("orderDate")->getDay()->lowerOrEqual(10)
    ->also("orderDate")->getFullYear()->equal(2015)
    ->getItems();
var_dump($result);

```

Hours:

```
$context = $this->getContext();
$result = $context->model("Order")
    ->where("orderDate")->getMonth()->equal(5)
    ->also("orderDate")->getDay()->lowerOrEqual(10)
    ->also("orderDate")->getHours()->between(10,18)
    ->getItems();
var_dump($result);

```

Minutes:

```
$context = $this->getContext();
$result = $context->model("Order")
    ->where("orderDate")->getMonth()->equal(5)
    ->also("orderDate")->getHours()->between(9,17)
    ->also("orderDate")->getMinutes()->between(1,30)
    ->getItems();
var_dump($result);

```

Seconds:

```
$context = $this->getContext();
$result = $context->model("Order")
    ->where("orderDate")->getMonth()->equal(5)
    ->also("orderDate")->getHours()->between(9,17)
    ->also("orderDate")->getMinutes()->between(1,30)
    ->also("orderDate")->getSeconds()->between(1,45)
    ->getItems();
var_dump($result);

```

#### Math Functions

[](#math-functions)

Round:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("price")->round()->lowerOrEqual(177)
    ->getItems();
var_dump($result);

```

Floor:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("price")->floor()->lowerOrEqual(177)
    ->getItems();
var_dump($result);

```

Ceiling:

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("price")->ceil()->lowerOrEqual(177)
    ->getItems();
var_dump($result);

```

#### Methods

[](#methods)

##### also(name)

[](#alsoname)

Prepares a logical AND expression.

Parameters:

- name: The name of field that is going to be used in this expression

##### andAlso(name)

[](#andalsoname)

Prepares a logical AND expression. If an expression is already defined, it will be wrapped with the new AND expression

Parameters:

- name: The name of field that is going to be used in this expression

    ```
      $context = $this->getContext();
      $result = $context->model("Product")
          ->where("category")->equal("Laptops")
          ->either("category")->equal("Desktops")
          ->andAlso("price")->round()->lowerOrEqual(250)
          ->getItems();
      var_dump($result);

    ```

##### expand(...attr)

[](#expandattr)

Parameters:

- attr: A param array of strings which represents the field or the array of fields that are going to be expanded. If attr is missing then all the previously defined expandable fields will be removed

Defines an attribute or an array of attributes to be expanded in the final result. This operation should be used when a non-expandable attribute is required to be expanded in the final result.

```
$context = $this->getContext();
$result = $context->model("Order")
    ->where("customer")->equal(337)
    ->orderByDescending("orderDate")
    ->expand("customer")
    ->getItem();
var_dump($result);

```

##### first()

[](#first)

Executes the specified query and returns the first item.

```
$context = $this->getContext();
$result = $context->model("User")
    ->where("name")
    ->equal("alexis.rees@example.com")
    ->first();
var_dump($result);

```

##### getItem()

[](#getitem)

Executes the specified query and returns the first item.

```
$context = $this->getContext();
$result = $context->model("User")
    ->where("name")
    ->equal("alexis.rees@example.com")
    ->getItem();
var_dump($result);

```

##### getItems()

[](#getitems)

Executes the specified query and returns an array of items.

```
$context = $this->getContext();
$result = $context->model("Product")
    ->where("category")
    ->equal("Laptops")
    ->getItems();
var_dump($result);

```

##### getList()

[](#getlist)

Executes the underlying query and returns a result set based on the specified paging parameters. The result set contains the following attributes:

- total (number): The total number of records
- skip (number): The number of skipped records
- records (Array): An array of objects which represents the query results.

    ```
      $context = $this->getContext();
      $result = $context->model("Product")
          ->where("category")
          ->equal("Laptops")
          ->take(10)
          ->getList();
      var_dump($result);

    ```

##### skip(val)

[](#skipval)

Prepares a paging operation by skipping the specified number of records

Parameters:

- val: The number of records to be skipped

    ```
      $context = $this->getContext();
      $result = $context->model("Order")
          ->skip(10)
          ->take(10)
          ->getItems();
      var_dump($result);

    ```

##### take(val)

[](#takeval)

Prepares a data paging operation by taking the specified number of records

Parameters:

- val: The number of records to take

    ```
      $context = $this->getContext();
      $result = $context->model("Order")
          ->take(10)
          ->getItems();
      var_dump($result);

    ```

##### groupBy(...attr)

[](#groupbyattr)

Prepares a group by expression

```
$context = $this->getContext();
$result = $context->model("Order")
    ->select("orderedItem/model as productModel",
        "orderedItem/name as productName",
        "count(id) as orderCount")
    ->where("orderDate")->getFullYear()->equal(2015)
     ->groupBy("orderedItem")
     ->orderByDescending("count(id)")
     ->take(5)
    ->getItems();
var_dump($result);

```

##### orderBy(...attr)

[](#orderbyattr)

Prepares an ascending sorting operation

```
$context = $this->getContext();
$result = $context->model("Product")
    ->orderBy("category","name")
    ->take(5)
    ->getItems();
var_dump($result);

```

##### thenBy(...attr)

[](#thenbyattr)

Continues a ascending sorting operation

```
$context = $this->getContext();
$result = $context->model("Product")
    ->orderBy("category")
    ->thenBy("name")
    ->take(5)
    ->getItems();
var_dump($result);

```

##### orderByDescending(...attr)

[](#orderbydescendingattr)

Prepares an descending sorting operation

```
$context = $this->getContext();
$result = $context->model("Product")
    ->orderByDescending("category","name")
    ->take(5)
    ->getItems();
var_dump($result);

```

##### thenByDescending(...attr)

[](#thenbydescendingattr)

Continues a descending sorting operation

```
$context = $this->getContext();
$result = $context->model("Product")
    ->orderByDescending("category")
    ->thenByDescending("name")
    ->take(5)
    ->getItems();
var_dump($result);

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4095d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/250e4f83e54fe1b0e4ce0d94a9c9f9806eb98ba9fcd08c3b6f3c1bd47fbf5453?d=identicon)[kbarbounakis](/maintainers/kbarbounakis)

---

Top Contributors

[![kbarbounakis](https://avatars.githubusercontent.com/u/9191768?v=4)](https://github.com/kbarbounakis "kbarbounakis (21 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/themost-phpclient/health.svg)

```
[![Health](https://phpackages.com/badges/themost-phpclient/health.svg)](https://phpackages.com/packages/themost-phpclient)
```

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

712181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91545.3M590](/packages/laravel-pail)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
