Download the PHP package themanwiththegoldenhand/lotr-php-sdk without Composer
On this page you can find all versions of the php package themanwiththegoldenhand/lotr-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download themanwiththegoldenhand/lotr-php-sdk
More information about themanwiththegoldenhand/lotr-php-sdk
Files in themanwiththegoldenhand/lotr-php-sdk
Package lotr-php-sdk
Short Description A PHP SDK for the LOTR API
License Apache-2.0
Informations about the package lotr-php-sdk
lotr-php-sdk
A Lord of the Rings (LOTR) PHP SDK
This is the PHP SDK for the Lord of the Rings API available at https://the-one-api.dev/v2.
Documentation for the API can be found at https://the-one-api.dev/documentation.
You will need to generate your own unique Access token, which you can obtain from https://the-one-api.dev/sign-up
Installation
You can install the LOTR SDK using Composer.
First, make sure you have Composer installed on your system.
Then, run composer init
and composer require themanwiththegoldenhand/lotr-php-sdk
.
Alternatively, you can download the LOTR.php
file and include it in your project manually.
Usage
To use the LOTR SDK in your project, you first need to create a new instance of the LOTR\LOTR class:
The usage examples in this README assume you have installed the package via Composer.
Make sure to replace YOUR_APIKEY
with the Access token, which you can obtain from https://the-one-api.dev/sign-up.
You can then use the client to make requests to the LOTR API. For example, to get a list of all movies:
The $response
variable will contain the response from the API, which you can then manipulate as needed.
Further Usage Examples
Get a list of all movies
Request one specific movie
Request all movie quotes for one specific movie
(only working for the LotR trilogy)
Get a list of all movie quotes
Request one specific movie quote
Limiting results
The movies service paginated with up to 2 results per page
Paginating results
The second page of the movies service paginated with up to 2 results per page
Offsetting results
The movies service paginated with up to 2 results per page and offset by 1 result
Note: If the offset is set, setting the page will not be applied
Sorting results
The movies results sorted by descending order of academyAwardWins
Note: Sorting can be applied against any valid key with either an asc
or desc
direction,
Filtering results (Example 1)
The character results filtered by those who are of Hobbit
or Human
race, do not have Blonde
hair and whose name contains king
.
Filtering results (Example 2)
The movies results filtered by those whose revenue was more than 1 billion and which won at least 1 academy award.
Building the filtering argument
The setFilters
function accepts a two-dimensional array. Each one of which must contain a value for key
and filter_type
.
All filter types other than exists
and not_exist
, must also have a value for value
.
The only accepted values for filter_type
are match
, not_match
, include
, exclude
, exists
, not_exist
, regex_match
, regex_not_match
, >
, <
, >=
and <=
.
If the filter_type
is one of >
, <
, >=
or <=
, then the value of value
must be numeric. For all other filter_type
values, the value for value
must be a non-empty string.
Disclaimers
This SDK is NOT a complete implementation. A greater emphasis has being put into the /movie
and /quote
services.
Testing
To run the unit tests for the LOTR SDK, first make sure you have PHPUnit installed and have added your Access token in the test file (tests/Test.php:8
). Then, run the following command from the root directory of the project:
This will run all the tests in the tests
directory.
Running all the tests in the project assumes you have cloned the repository.
Contributing
If you find any bugs or have any feature requests, please open an issue on the GitHub repository. Pull requests are also welcome!
License
This SDK is licensed under the Apache-2.0 license. See the LICENSE file for more information.
All versions of lotr-php-sdk with dependencies
ext-curl Version *
ext-json Version *