Download the PHP package elan-ev/opencast-api without Composer

On this page you can find all versions of the php package elan-ev/opencast-api. 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 opencast-api

opencast-php-library

This PHP composer package is meant to provide a unified easy-to-use Opencast RESTful API library. It has been designed to make most of commonly used REST Endpoints available to the developers of thirt-party applications mainly LMSes such as Stud.IP, Moodle and ILIAS. Please refer to the Change Log for more info.

Note

As of version 1.2.0 the main class name has been changed from OpenCast to OpenCast. Please refer to Upgrade Log for more info.

Requisitions

PHP Version 7.2.5 or above as well as cURL are required. Additionaly, the requirements of guzzlehttp/guzzle must be fullfiled.

Installation

composer require elan-ev/opencast-api

Basic Usage

There are 2 approaches to use the Opencast REST Endpoints from this library:

  1. The first one is via the generic OpencastApi\Opencast which contains all available Opencast endpoints (which are capable with the API version defined in the config). The advantage of using this approach is a better control over all available endpoints. (Recommended)

NOTE: When using this library against a distributed Opencast setup with admin and presentation split, you can pass another set of configuration as the second parameter when instantiating the OpencastApi\Opencast. Initially, the presentation node only takes care of search endpoint.

  1. The second approach is to instantiate each REST endpoint class, which are located under OpencastApi\Rest\ namespace, when needed, but the down side of this is that it needs a OpencastApi\Rest\OcRestClient instance as its parameter. The advantage of this approach might be the methods' definitions in the IDE.

Configuration

The configuration is type of Array and has to be defined as follows:

UPDATE (v1.9.0): a new config parameter called "guzzle" is introduced, which is intended to pass additional guzzle request options to the call. These options will take precedence over the default configs like uri, auth and timeouts, but some other options like query, fome_params and json will be overwritten by the function if present. UPDATE (v1.7.0): the new items called features is added to the configuration array. As of now, it is meant to hanlde the toggle behavior to enable/disable Lucene search endpoint simply by adding 'features' => ['lucene' => true]. Just keep in mind that this endpoint id off by default and won't work in Opencast 16 onwards. Therefore, developer must be very careful to use this feature and to toggle it!

NOTE: the configuration for presentation (engage node) responsible for search has to follow the same definition as normal config. But in case any parameter is missing, the value will be taken from the main config param.

Extra: Dynamically loading the ingest endpoint class into Opencast instance.

As of v1.3 it is possible to enable (Default) or disable the ingest endpoint to be loaded into OpencastApi\Opencast by passing a boolean value as the last argument of the class as follows:

Response

The return result of each call is an Array containing the following information: From v1.4 the 5th response parameter 'origin' is available!

Filters and Sorts

Filters and Sorts must be defined as associative Array, as follows:

NOTE: Sometimes a filter can occur multiple times for example in Series API /get, filters like subject and identifier can occur multiple times. Therefore, an Array should be passed as filter value like following:

runWithRoles([])

Sometimes it is needed to perform the request with a disposable header of X-RUN-WITH-ROLES containing some roles (e.g. user ids) in order for Opencast to assume that those users has special access right.
It is commonly used to get data with onlyWithWriteAccess parameter for example to perform getAll in OcSeriesApi and grab those series that only specified users have access to!
In order to perform such requests it is needed to call the runWithRoles method before calling the desired function in a class:
NOTE: This method accepts an Array defining the roles to check against!

NOTE: Roles can be either an Array including each role, or a comma separated string!

runAsUser($user)

Sometimes it is needed to perform the request with a disposable header of X-RUN-AS-USER containing the user id in order for Opencast to assume that this user has access right. This feature is added since v1.4. NOTE: This method accepts an String defining the user id to check against!

noHeader()

In order to perform a request call to an endpoint without any request headers/options, you can use this method before calling the desired function in an endpoint class: NOTE: This method accepts nothing (void).

setRequestTimeout($timeout = 0)

In order to perform a request call with a different timeout value other than the one set in the configuration, you can use this method before calling the desired function in an endpoint class: NOTE: This method accepts integer defining a single use timeout in second.

setRequestConnectionTimeout($connectionTimeout = 0)

In order to perform a request call with a different connection timeout value other than the one set in the configuration, you can use this method before calling the desired function in an endpoint class: NOTE: This method accepts integer defining a single use connection timeout in second.

Available Opencast REST Service Endpoint

Mocking Responses

In order to conduct proper testing, a mocking mechanism is provided.

How to use

Step 1: Responses Array

As in the first step it is necessary to have all the responses in an array form, which has to have the following structure:

NOTE: In order to apply multiple calls to the same path, a unique parameter called unique_request_identifier in params array must be provided, for example you want to update a series's acl twice with the same path but different acl values: (The value of the unique identifier must be something within the body of the request)

Step 2: Creating a new MockHandler instance and passing to the configuration array.

In order to create a new MockHandler instance, you should use \OpencastApi\Mock\OcMockHanlder::getHandlerStackWithPath and pass that instance into the configuration array with handler key, like so:

Extra: Log requests uri

if you want to have a list of request uri, you can pass a file path variable as the second argument into the \OpencastApi\Mock\OcMockHanlder::getHandlerStackWithPath to write/append every uri into that file, like so;

Naming convention

Classes:

Apart from 'Opencast' class, all other classes under OpencastApi\Rest\ namespace start with Oc followed by the name and the endpoint category. For example:

Opencast class properties:

The naming convention to access the endpoint subclasses from OpencastApi\Opencast as its properties, includes the name of the class without Oc in camelCase format. For example:

References


All versions of opencast-api with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.5
guzzlehttp/guzzle Version >=7.5.1
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 elan-ev/opencast-api contains the following files

Loading the files please wait ....