Download the PHP package networkrailbusinesssystems/maximo-query without Composer

On this page you can find all versions of the php package networkrailbusinesssystems/maximo-query. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package 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

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

Configuration

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

Usage

Query Builder

You can either use the facade

or by creating a new instance of the MaximoQuery class

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

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:

Or an array of columns:

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

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

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:

Other Where Methods

Ordering

You can request that the returned data is ordered using the orderBy method which accepts the column name and the direction to sort by desc / asc

Or you can sort by multiple columns

Paging

Because of the potential to request a large amount of data, the query builder has a default of 1000 resource items per page.

This can be overridden using the paginate() method:

To retrieve a specific page, pass the page number to the get() method:

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

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

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.

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.

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

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

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

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. https://system/one and https://system/two) 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 a new resource is as simple as calling the create method and passing an array:

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:

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

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:

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:

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:

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

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

The response can be converted into an array

or an Illuminate\Support\Collection

To retrieve the query URL directly from the response object

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

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

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.

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:

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

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

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

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of maximo-query with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
guzzlehttp/guzzle Version ^7.3
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package networkrailbusinesssystems/maximo-query contains the following files

Loading the files please wait ....