Download the PHP package js361014/plankton without Composer

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

Plankton: a RESTful API microframework

Requirements

Installation

composer require foxdie/rest

Table of content

Client

Creating a client

Full example here: https://github.com/foxdie/rest/blob/master/Test/public/simple-client.php

GET example

using callback

using magic

POST example

using callback

using magic

PUT, PATCH and DELETE examples

Full example here: https://github.com/foxdie/rest/blob/master/Test/public/simple-client.php

Magic calls

Spinal case

If you want to use magic calls, your routes must use the spinal case Example:

$client->getUserAccounts()

will match the following route:

GET /user-accounts

camel case and snake case are not supported

Examples

call route
$client->getUsers(); GET /users
$client->groups(1)->getUsers(); GET /groups/1/users
$client->groups(1)->getUsers(2); GET /groups/1/users/2
$client->postUsers([]); POST /users
$client->groups(1)->postUsers([]); POST /groups/1/users
$client->deleteUsers(1); DELETE /users/1
$client->users(1)->delete(); DELETE /users/1
$client->groups(1)->deleteUsers(2); DELETE /groups/1/users/2
$client->groups(1)->users(2)->delete(); DELETE /groups/1/users/2
$client->groups(1)->users()->delete(2); DELETE /groups/1/users/2

Content types

When you are using magic calls (e.g. $client->postUsers([]);) or one of the methods Client::post(), Client::put(), Client::patch(), a Content-Type header is automatically added to the request. The Content-Type is automatically guessed according to the data you send to the server :

data type Content-Type
array application/x-www-form-urlencoded
object application/json
valid json string application/json
valid xml string application/xml
string text/plain

However, you still can set the Content-Type manually with a customized request

Custom request example

Automatic data conversion

For readability reasons, you can use arrays or objects with the Request::setData() method, regardless of the content-type you use. The data will be automatically converted according to the rules below :

Content-Type Data type Conversion
Request::CONTENT_TYPE_JSON array json string
Request::CONTENT_TYPE_JSON object json string
other array URL-encoded query string
other object URL-encoded query string

Authentication strategy

anonymous auth

basic auth

client credentials

The authorize and access/refresh token requests will be performed automatically. The 3rd parameter is optionnal, the default value is "/token"

Server

Creating a server

Full example here: https://github.com/foxdie/rest/blob/master/Test/public/simple-server.php

Creating controllers

You must create at least one controller which extends the abstract class Plankton\Server\Controller

Your controller will contain one public method for each action of your API.

You can create routes in 2 different ways:

Using a config file

This will automatically disable the annotation parser. The routes are described in a YAML file

Example of config file

Full example here: https://github.com/foxdie/plankton/blob/master/Test/config/server.yml

Configuring the server

Full example here: https://github.com/foxdie/plankton/blob/master/Test/public/config-server.php

Using annotations

The routes will be created automatically according to the annotations @Route and @Method.

Full example here : https://github.com/foxdie/rest/blob/master/Test/Controller/APIController.php

@Route annotation

You can add a route prefix to your controller:

@Method annotation

Possible values are:

@Exception annotation

Registering controllers

Full example here: https://github.com/foxdie/rest/blob/master/Test/public/simple-server.php

Creating middlewares

(this is optionnal) You must implement the Plankton\Server\Middleware interface. The middlewares can handle both incoming requests and outgoing responses.

Full example here: https://github.com/foxdie/rest/blob/master/Test/Middleware/BasicAuthenticationMiddleware.php

Registering the middlewares

OAuth2

Client Credentials Grant

Client

Full example here:
https://github.com/foxdie/rest/blob/master/Test/public/oauth2-client.php

Server

Full example here: https://github.com/foxdie/rest/blob/master/Test/public/oauth2-server.php

Creating your own Access Token Provider

All you have to do is to implement the AccessTokenProvider interface:

Logging

Client side

Simple logger

Full example here: https://github.com/foxdie/rest/blob/master/Test/public/simple-client.php

XML logger

Full example here: https://github.com/foxdie/rest/blob/master/Test/public/oauth2-client.php

Custom logger

You have to implement the Plankton\Request\Logger interface:

Server side

You can easily log requests and responses by adding a middleware:

and then register the middleware(#registering-the-middlewares)


All versions of plankton with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.0
ext-curl Version *
symfony/yaml Version ^4.2@dev
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 js361014/plankton contains the following files

Loading the files please wait ....