Download the PHP package flame/tiny-rest without Composer

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

Nette REST library

Smart and tiny implementation of REST API for Nette framework

Content

  1. Requirements
  2. Installation
  3. Configuration
  4. Authentication
  5. Routing and presenters
  6. Examples
  7. Patrons

Requirements

For full requirements list please see this file

Installation

The best way to install flame\tiny-rest is using Composer

and register extension:

Configuration

This package provide next options:

Example configuration:

Authentication

This package provide several authorization method.

  1. Authorization by IP address - this authorization is enabled automatically when you set ips option in config file.
  2. Authorization by HTTP referer - this authorization is enabled automatically when you set referers option in config file
  3. Authentication by settings for cross-domain requests - this authorization is automatically enabled when you set cors option in config file and respects this rules

Next authorization methods is token-based authorization. For this authorization type you must do some steps:

  1. You can create own authenticator implements Flame\Rest\Security\IAuthenticator or you can use default authenticator from this package
  2. You must create own token provider class implements Flame\Rest\Security\Tokens\ITokenProvider. This class with getToken() must get token from request (request is provided as argument) and create and return a new instance of Flame\Rest\Security\Tokens\IToken (there you must create own implementation or you can use default)
  3. You must create own implementation of Flame\Rest\Security\Tokens\ITokenManager wḧich provides method for validate token and getting identity for concrete token.

Implementation you can see in Examples.

Routing and presenters

Routing

This package provides one basic route:

This route has one optional argument with module path for searching presenter. In this example expects models with names Api and V1.

Structure of URLs which is created by this router is /<module>/<presenter>[/<specific_action>][/<id>]. For our example will be /api/v1/<presenter>[/<specific_action>][/<id>]

All this URLs is mapped to actions in presenter by rule action<create|update|read|readAll|delete><specific_action>(<id>) when POST = create, PUT = update, DELETE = delete, GET without id = readAll and GET with id = read. For example:

Presenter

All API presenters should be extended from RestPresenter. When you can send data you must it write into resource:

or for better works you can use data property of resource

Sending responses is automatically on end of action method with HTTP code 200. When you can change it, you must call sendResource($code) manually.

And for processing and logging errors you can use sendErrorResponse method.

You can get data from POST, or query by input or getInput() member. You can get query values by getQuery(), POST values by getData() or FILES by getFiles()

Examples

Router:

Presenter AccountsPresenter.php

Create own Token implementation:

Create a own TokenGetter:

Create own TokenManager

In this example when I send GET request on /api/v1/accounts with Authorization: valid header and use BasicAuthenticator for authenticate by @User annotation API returns identity of logged user.

Patrons

Big thanks to these guys!


All versions of tiny-rest with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.2
nette/nette Version >=2.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 flame/tiny-rest contains the following files

Loading the files please wait ....