Download the PHP package govtnz/silverstripe-api without Composer

On this page you can find all versions of the php package govtnz/silverstripe-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 silverstripe-api

silverstripe-api

A facade pattern API implementation for SilverStripe using interfaces and optionally Swagger.

Build Status Version

Introduction

This is an opinionated package that implements a SilverStripe API with the following features:

You can structure your API in whatever way makes the most logical sense to its consumers: this is the facade pattern.

In many cases the class implementing an interface could be an existing Page Controller, but you're entirely free to have a separate class purely for implementing the API interface.

This package is being developed progressively by the Govt.nz team, and features are being added as they're required for our own project.

This means that some desirable features have not yet been implemented.

OAuth and permissions checking, for example, will only be added when we need them ourselves.

Quick start

The /resources/data_dir subdirectory within this module contains interface samples.

  1. Copy the entire subdirectory to a suitable location (see API data below).
  2. Run dev/build.
  3. Run dev/tasks/ApiRebuildDefinitionsTask
  4. In a web browser, type [WEBROOT]/api/v1/section/list ... you should see a correctly formatted response.

Use Swagger-UI or manually browse the assets/api/v1/swagger.json file to learn the other available API requests.

Configuration

API definitions

silverstripe-api allows you to break your API definition into blocks distributed across multiple files.

It's not mandatory to split up your API definition: if you wish, you can write it as a single block. But splitting it up improves maintainability, and the dev task API: Rebuild definitions will still generate a single swagger.json file for each API version.

However you structure your API definition, it needs to be

  1. standard JSON,
  2. aligned with the Swagger 2.0 specification, and
  3. contained in mulit-line comment blocks:

Unlike a regular JSON file, you can include // comments in your API definitions (but don't use /* */ comments). These // comments will be ignored by the dev task that generates the swagger.json output. The dev task will assume that each chunk of JSON is a top-level element within the Swagger definition: the provided examples demonstrate this.

Swagger JSON file

The dev task API: Rebuild definitions takes the JSON fragments from each interface and builds them into a single swagger.json file.

By default the resulting swagger.json file is saved in /assets/api, but you can change that with a .yml config setting:

And if you're integrating govtnz/swagger-ui with this API module, this path must be externally accessible.

Definitions File

Each API directory must have a file which defines properties that are common across all the interface nodes.

There are two useful variables available within this text file which can make your API definitions more portable between dev, test and production servers:

You can use getHost to automatically populate the "host" key:

You can use getProtocol to automatically populate the "schemes" array:

It's recommended that you copy and modify the existing resources/base.txt file to kick-start your own API development.

Tests

Automated tests can be written to exercise each interface and its stub file. These can be stored in the /tests subdirectory.

Each file in the stubs directory implements an API interface using static data. It is invoked in one of two circumstances:

  1. When a test parameter is added to an API request, for example &test=true.
  2. When there is no other implementation of an API interface.

Stub files are not mandatory, but they're useful for testing as their responses never change.

API Documentation

There are several useful functions in the ApiController:

Implementation

Your implementation code can:

Your implementation must:

For example, the API method organisation/sector returns a list of organisation sectors, not a list of organisations. In this instance set pronoun to sector so the output is appropriately described.

Swagger integration

There is a companion package, govtnz/swagger-ui, which forks Swagger UI and makes it easy to include in a SilverSripe project.

See the documentation within this companion Swagger package for more details.


All versions of silverstripe-api with dependencies

PHP Build Version
Package Version
Requires silverstripe/framework Version ~3.1
silverstripe/cms Version ~3.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 govtnz/silverstripe-api contains the following files

Loading the files please wait ....