Download the PHP package sainsburys/sainsburys-http-service without Composer

On this page you can find all versions of the php package sainsburys/sainsburys-http-service. 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 sainsburys-http-service

Build Status Scrutinizer Code Quality

logo

Sainsburys HTTP Service Framework

PHP micro-framework for small REST or HTTP RPC services. Built and open sourced by J Sainsbury plc.

The framework is basically a wrapper for the Slim micro-framework in PHP, but works only with a more structured application.

It relies on Slim 3.

Version 1.x.x is an LTS version with support for PHP 5.5. Version 2.0.0 and subsequent require PHP 7.

Basic Usage

See the sample application for an example of how to use it. The sample application is used by the automated tests as well, so will be up-to-date.

Core Concepts

Standards Compliance

The framework aims to comply with the PSR-3 standard for interchangable loggers, the PSR-7 standard for interchangable HTTP request and response objects, the Container-Interop standard for interchangable Dependency Injection Containers, and with semantic versioning in its release numbers.

Controllers and Dependency Injection

This is what a controller should look like:

Controllers must be objects, not closures. No abstract controller is provided - controllers should be stand-alone objects with no inheritance. Controllers will be retrieved from a dependency injection container.

Your routing config will map a route pattern to the service ID of the controller. Provide a Container Interop container with your controllers in it. A standards-compliant Pimple 3 wrapper is used in the example index file provided.

Try looking at the example routing file and typical dependency injection configuration for a clear example of this. Your routing config file may be a .php 'return array' file, a JSON file, a YAML file or a .ini file.

Controller Actions - acceptable return types

Controller actions must return a PSR-7 HTTP Response object. The parametric response is a Zend Diactoros .

Middlewares

To use middlewares in the framework, call . You can add your own implementations of the and interfaces to a list. They will run accordingly.

Exception Handling

Throwing an uncaught exception from a controller will cause a response with the exception details encoded in JSON. The status code will usually be 500. If the exception implements , the status code on the exception will be used.

If you wish to implement your own error handler, for example if you don't want stack traces being visible in the response in production, call in your file, and give it a different error controller it can use.
is provided if you wish to use an error controller with less verbose output.

Error Logging

Your error controller will be passed a , which by default will be a . This does nothing. To do error logging, call . You will need a PSR-3 compliant logger for this. We suggest that you pass your choice of logging object into your other controllers or other classes as well, where logging is required. You can do this when you configure the dependencies of your controller in your DI container. The Monolog logging tool may be a good choice of logging library in PHP if you are looking for ideas.

Installation

Use Composer.

You may also need to require , depending on your project's composer settings. This will change shortly.

Testing

Check the project out, run Composer, and type to run all the tests. Read that shell script for specific test commands.


All versions of sainsburys-http-service with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
slim/slim Version ^3.0.0
container-interop/container-interop Version ~1.1.0
psr/http-message Version 1.0.0
psr/log Version 1.0.0
shrikeh/teapot Version ^1.0
ultra-lite/container Version ^2.0
samburns/config-file-parser Version ^1.0
zendframework/zend-diactoros Version ^1.0
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 sainsburys/sainsburys-http-service contains the following files

Loading the files please wait ....