PHPackages                             networkrailbusinesssystems/maximo-query - 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. [API Development](/categories/api)
4. /
5. networkrailbusinesssystems/maximo-query

ActiveLibrary[API Development](/categories/api)

networkrailbusinesssystems/maximo-query
=======================================

A Laravel package to easily retrieve data from Maximo using the REST API

4.0.1(3y ago)02.0k—8.3%MITPHPPHP ^8.0

Since Jun 2Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/Network-Rail-Business-Systems/maximo-query)[ Packagist](https://packagist.org/packages/networkrailbusinesssystems/maximo-query)[ Docs](https://github.com/Network-Rail-Business-Systems/maximo-query)[ RSS](/packages/networkrailbusinesssystems-maximo-query/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (7)Versions (10)Used By (0)

Maximo Query
============

[](#maximo-query)

This package enables you to retrieve and update data from Maximo using a custom query builder.

**IMPORTANT**: v2 of the package has breaking changes and should not be used in existing projects without taking the necessary refactoring into account. Please see the upgrade section for more information.

Installation
------------

[](#installation)

To add this package to your project, simply run the following command:

```
composer require networkrailbusinesssystems/maximo-query

```

#### Configuration

[](#configuration)

Publish the config file and configure the `maximo_url`, `maximo_username` and `maximo_password` parameters.

```
php artisan vendor:publish --provider="NetworkRailBusinessSystems\MaximoQuery\Providers\MaximoQueryServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

### Query Builder

[](#query-builder)

You can either use the facade

```
$query = MaximoQuery::withObjectStructure('mxperson');

```

or by creating a new instance of the `MaximoQuery` class

```
$query = (new MaximoQuery)->withObjectStructure('mxperson');

```

#### Query Object

[](#query-object)

You must define a Maximo data object to query against by using the `withObjectStructure` method which takes the name of the object structure as its only parameter.

Not defining the data object will result in an exception being thrown.

#### Selecting Columns

[](#selecting-columns)

By default, the query will not select anything and the request will just return the resource links for the individual records.

You can select data using the select method and passing in the columns requested:

```
$query = MaximoQuery::withObjectStructure('mxperson')
    ->select('displayname');

```

Or an array of columns:

```
$query = MaximoQuery::withObjectStructure('mxperson')
    ->select(['personuid', 'displayname']);

```

You can also select all the column available on the given object using:

```
$query = MaximoQuery::withObjectStructure('mxperson')
    ->selectAll();

```

This should be used with **caution** as many objects in Maximo have a **LOT** of columns! It is far better to specify exactly what columns are required in order to reduce the response payload.

#### Where Clauses

[](#where-clauses)

Adding a basic where cause can be done simply by calling the `where` method.

Like eloquent, the `where` method accepts three parameters `$column`, `$operator` and `$value` and if only two parameters are passed, the `=` operator is assumed.

The following `$operators` can be used:

- `=` equals
- `>=` greater than equals
- `>` greater than
- `paginate(20)
    ->get(2);

```

If you wish to disable pagination completely use the `withoutPagination()` method:

```
$query = MaximoQuery::withObjectStructure('mxperson')
    ->withoutPagination();

```

Be **VERY** careful when disabling pagination and ensure that your query has been sufficiently filtered down or you could end up with a very **LARGE** response payload!

#### Record Count

[](#record-count)

If you only want to retrieve the number of records for your given query you can use the `count()` method. This will immediately execute your request and return the record count.

```
MaximoQuery::withObjectStructure('mxperson')
    ->where('lastname', 'Thompson')
    ->count();

```

If you wish to return the record count with the resource collection you can use the `withCount()` method. This will include a `totalCount` attribute with the requested data.

```
MaximoQuery::withObjectStructure('mxperson')
    ->select(['personuid', 'displayname'])
    ->where('lastname', 'Thompson')
    ->withCount()
    ->get();

```

#### Null Values

[](#null-values)

By default, all requested columns are returned regardless of their values. If you wish to reduce the response payload, you may request that `null` values are not included in the response by using the `filterNullValues()` method.

#### Retrieving A Specific Record

[](#retrieving-a-specific-record)

Like Eloquent, you can use the `find()` method to retrieve a single resource by passing in the unique ID. This will immediately send the request and, if found, return the requested resource as an array of `attribute => value` pairs.

#### Executing The Query And Retrieving The Resource

[](#executing-the-query-and-retrieving-the-resource)

Almost all the methods return the current instance and as such can be chained to your heart's content.

Once you are finished building the query, simply calling `get()` will execute the query and return an instance of the `MaximoResponse` class.

#### Authentication

[](#authentication)

Upon executing the query, the package make an initial request to authenticate using the `maximo_username` and `maximo_password` variables set in the config file.

The cookies returned are then sent as part of the main request payload.

The authentication cookies are stored in the cache for the configured cache lifetime specified in the `cache_ttl_minutes` config variable thus removing the need to authenticate for subsequent requests.

If you are running multiple sites from the same domain (e.g.  and ) each will require its own cookie key to avoid cross-site interference. This can be set in the config or the system `.env` using the `MAXIMO_KEY` setting.

### Creating Resources

[](#creating-resources)

Creating a new resource is as simple as calling the `create` method and passing an array:

```
$response = MaximoQuery::withObjectStructure('trim')
	->create([
		'class' => 'SR',
		'assetsiteid' => 'TRIM',
		'siteid' => 'TRIM',
		'nrbusinessarea' => 'Internal to NR',
		'assetnum' => 'MAXIMO',
		'description' => 'Some Title',
		'description_longdescription' => 'Some description',
		'reportdate' => Carbon::Now()->format('Y-m-d\TH:i:s+00:00'),
		'nraffectedperson' => 'Jon Doe',
		'nraffectedemail' => 'jon.doe@networkrail.co.uk',
	]);

```

#### Adding Attachments To Resources

[](#adding-attachments-to-resources)

Adding files to the resource to be created is as simple as calling the `withAttachments` method before `create`and passing in one or more `Illuminate\Http\UploadedFile` objects:

```
$fileOne = $request->fileOne;
$fileTwo = $request->fileTwo;

$response = MaximoQuery::withObjectStructure('trim')
	->withAttachments($fileOne, $fileTwo)
	->create([
		...
	]);

```

This will create the necessary structure for each file, extract the file name, base64 encode the content and append it to the data passed into the `create` method.

#### Properties

[](#properties)

By default, the response from the `create` method will only return the `href` of the newly created resource. To retrieve additional data in the response, you can pass in an array of properties as the 2nd parameter of the `create` method:

```
$response = MaximoQuery::withObjectStructure('trim')
	->withAttachments($fileOne, $fileTwo)
	->create(
		[...],
		['href', 'ticketid', 'description']
	);

```

### Updating Resources

[](#updating-resources)

In order to update a resource in Maximo, you must first have the unique URL of the resource in question. By fluently constructing your query to contain one or more where clauses, the package will retrieve the resource url and then use it to make the update request:

```
$response = MaximoQuery::withObjectStructure('trim')
	->where('ticketid', 'DOE12345')
	->update([
		'description' => 'A new title',
	]);

```

Like the `create` method, by default only the `href` of the resource is returned and additional data can be returned by passing in an array of properties as the 2nd parameter of the `update` method.

**IMPORTANT**There are several instances where an exception will be thrown when using the `update` method:

- If no where clause has been specifed
- If more than one resource is returned
- If no resources where found

While attachments cannot be deleted via the API, they can be added while updating a resource using the `withAttachments` method described above.

### MaximoResponse Object

[](#maximoresponse-object)

All successful responses return a `MaximoResponse` object. The response object is immutable so all the methods below can be called without affecting the original object.

To get the raw `Illuminate\Http\Client\Response` object, simply call

```
$obj = $response->raw();

```

The response can be converted into an array

```
$array = $response->toArray();

```

or an `Illuminate\Support\Collection`

```
$collection = $response->toCollection();

```

To retrieve the query URL directly from the response object

```
$url = $response->getUrl();

```

You can search the response recursively for a key and have it return the corresponding value:

```
$value = $response->filter('member');

```

You can also choose to return the filtered data as a `Illuminate\Support\Collection` by passing in the 2nd boolean parameter:

```
$collection = $response->filter('member', true);

```

If the key cannot be found a `KeyNotFound` exception is thrown.

If you requested that the record count be returned with the response payload, you can call the `getCount()` method on the response to retrieve it.

```
$count = $response->getCount();

```

If you call this method without having called the `withCount()` method on the query, a count of `0` will be returned.

To retrieving the next or previous page of a paginated response can be done like so:

```
$pageTwo = $response->nextPage();
$pageOne = $pageTwo->previousPage();
$pageThree = $pageTwo->nextPage();

```

Calling either of these methods makes another http request and returns a new instance of the `MaximoResponse` object.

### Upgrading To V2

[](#upgrading-to-v2)

The response returned from Maximo is no longer namespaced i.e. `rdfs:member` to simplify and reduce the response payload. Simply removing the prefix is all that is needed for this change.

The `raw` method of the `MaximoResponse` class now returns an instance of `Illuminate\Http\Client\Response` instead of a JSON string.

A new `MaximoQuery` instance is returned when using the Facade rather than the cached singleton as with previous versions. This means calling `MaximoQuery::withObjectStructure('trim')` is the same as calling `(new MaximoQuery())->withObjectStructure('trim')`.

### Testing

[](#testing)

When utilising MaximoQuery in your tests, you can apply your expectations directly to the class instead of making your own mocks:

```
MaximoQuery::shouldReceive('withObjectStructure')
    -> andThrow(new InvalidResponse());

```

Credits
-------

[](#credits)

- [Christopher Abey](https://github.com/chrisabey84)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance46

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 71.4% 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

Every ~106 days

Recently: every ~114 days

Total

9

Last Release

1327d ago

Major Versions

0.4 → 2.02021-06-29

2.1.0 → 3.02022-04-08

3.0 → 4.0.02022-09-13

PHP version history (4 changes)0.1PHP ^7.4

0.4PHP 7.4 - 8.0

2.0PHP 8.0

3.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/17785811?v=4)[Anthony Edmonds](/maintainers/AnthonyEdmonds)[@AnthonyEdmonds](https://github.com/AnthonyEdmonds)

---

Top Contributors

[![AnthonyEdmonds](https://avatars.githubusercontent.com/u/17785811?v=4)](https://github.com/AnthonyEdmonds "AnthonyEdmonds (15 commits)")[![AmbreenJamal](https://avatars.githubusercontent.com/u/26721392?v=4)](https://github.com/AmbreenJamal "AmbreenJamal (4 commits)")[![chrisabey84](https://avatars.githubusercontent.com/u/59964241?v=4)](https://github.com/chrisabey84 "chrisabey84 (2 commits)")

---

Tags

laravelnetwork railmaximo-querymaximo

###  Code Quality

TestsPest

Static AnalysisRector

### Embed Badge

![Health badge](/badges/networkrailbusinesssystems-maximo-query/health.svg)

```
[![Health](https://phpackages.com/badges/networkrailbusinesssystems-maximo-query/health.svg)](https://phpackages.com/packages/networkrailbusinesssystems-maximo-query)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[statamic/cms

The Statamic CMS Core Package

4.8k3.2M720](/packages/statamic-cms)[irazasyed/telegram-bot-sdk

The Unofficial Telegram Bot API PHP SDK

3.3k4.5M84](/packages/irazasyed-telegram-bot-sdk)[flat3/lodata

OData v4.01 Producer for Laravel

96320.9k](/packages/flat3-lodata)[laravel-freelancer-nl/laravel-index-now

Alert search engines of content changes.

5212.1k](/packages/laravel-freelancer-nl-laravel-index-now)[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

762.6k](/packages/scriptdevelop-whatsapp-manager)

PHPackages © 2026

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