PHPackages                             poqcz/restler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. poqcz/restler

ActiveLibrary[Framework](/categories/framework)

poqcz/restler
=============

Restler is a simple and effective multi-format Web API Server framework written in PHP. Just deal with your business logic in php, Restler will take care of the REST!

4.1.8(9y ago)1222LGPL-2.1JavaScriptPHP &gt;=5.3.0

Since May 10Pushed 9y ago1 watchersCompare

[ Source](https://github.com/poqcz/Restler)[ Packagist](https://packagist.org/packages/poqcz/restler)[ Docs](http://luracast.com/products/restler/)[ RSS](/packages/poqcz-restler/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (10)Versions (22)Used By (0)

[![Restler](public/examples/resources/Restler.png)](public/examples/resources/Restler.png) Luracast Restler
===========================================================================================================

[](#-luracast-restler)

[!\[Gitter\](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/Luracast/Restler?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)[![Latest Stable Version](https://camo.githubusercontent.com/196d1b471b741460c5c19513d8125ace513303655fa10bc8d5e37d0eb1801a94/68747470733a2f2f706f7365722e707567782e6f72672f6c757261636173742f726573746c65722f762f737461626c652e706e67)](https://packagist.org/packages/luracast/restler) [![Total Downloads](https://camo.githubusercontent.com/f9a2cd37cbad693e24b52a7a39e5342d7a8c4ced96bd412bcebdf41c614ea659/68747470733a2f2f706f7365722e707567782e6f72672f6c757261636173742f726573746c65722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/luracast/restler) [![Latest Unstable Version](https://camo.githubusercontent.com/234bb353043083ac6a6b17aab98a81091e21818c091740266c1c0efc6917b070/68747470733a2f2f706f7365722e707567782e6f72672f6c757261636173742f726573746c65722f762f756e737461626c652e706e67)](https://packagist.org/packages/luracast/restler) [![License](https://camo.githubusercontent.com/f8bb9c31afb9e36f42be178cb272e527eb14d10a505562620f175baccb94a166/68747470733a2f2f706f7365722e707567782e6f72672f6c757261636173742f726573746c65722f6c6963656e73652e706e67)](https://packagist.org/packages/luracast/restler)

### Version 3.0 Release Candidate 5

[](#version-30-release-candidate-5)

Restler is a simple and effective multi-format Web API Server written in PHP.

Just deal with your business logic in php, restler will take care of the REST!

> if you do not have PHP &gt;= 5.3.2 on your server and wont be able to upgrade you may use [Restler 2](https://github.com/Luracast/Restler/tree/v2) instead

### Restler 3 - *Better APIs by Design*

[](#restler-3---better-apis-by-design)

- [Developer Home](http://luracast.com/products/restler/)
- [Live Examples](http://bit.ly/Restler3LiveExamples)
- Updates on [Facebook](https://www.facebook.com/Luracast) and [Twitter](http://twitter.com/Luracast)
- [Features](#features)
- [Installation](#installation)
- [Quick Start Guide](#quick-start-guide)
- [Change Log](#change-log)

Features
--------

[](#features)

- No Learning Curve
- Light weight
- Flexible
- Highly Customizable
- Many Examples that can be tried on your localhost to get started
- Supports HTTP request methods HEAD, GET, POST, PUT, DELETE, OPTIONS and PATCH via header or request parameter (method)
- Supports both RESTful and Pragmatic REST API Design
- Clients can use X-HTTP-Method-Override header, supports Cross Origin Resource Sharing and JSONP
- Two way format(media type) conversion both send and receive
    - Pluggable content Formatter framework and api
    - Comes with JSON, XML, Yaml, Amf, and Plist(both XML and Binary) format support
- Pluggable Authentication schemes
    - OAuth 2 Server
- Pluggable Filters to effectively manage API usage
    - API Rate Limiting Filter
- Routing
    - Manual Routing (Annotation)
        - Using `@url GET my/custom/url/{param}` PHPDoc comments
    - Auto Routing (Reflection)
        - URL to Method mapping
        - URL part to Method parameter mapping
        - Query parameters to Method parameter mapping
        - Request body to Method parameter mapping
        - `[planned]` Header to Method parameter mapping
- Cache built-in
    - Client Side Caching support
    - Proxy Caching support
    - Server Side Caching
        - `[planned]` ETag, If-None-Match support
        - `[planned]` Last-Modified, If-Modified-Since support
- API Features
    - Always supports URLEncoded format for simplified input (POST vars)
    - Automatic parameter validation and type conversion
    - API versioning support by URL and/or vendor specific MIME
    - API documentation and discovery using [Restler API Explorer](https://github.com/Luracast/Restler-API-Explorer)
    - Throttling and Performance tuning
- Management
    - `[planned]` Unit Testing using [PHPUnit](https://github.com/sebastianbergmann/phpunit/)
    - Behavior Driven API testing using [Behat](http://behat.org/) and [Guzzle](https://github.com/guzzle/guzzle)
    - Command line Project Management using [Respect/Foundation](https://github.com/Respect/Foundation)
    - Dependency Management using [Composer](http://getcomposer.org/)
    - Source code distributed under LGPL

Git Repository and the Branches
-------------------------------

[](#git-repository-and-the-branches)

1. Most stable and recent version is maintained at the `master` branch, previous versions are kept in the branches such as `v1` and `v2`
2. Version branch with the current version such as `v3` is used for building up the next release. It's documentation may not be updated frequently and thus reserved for the daring ones.
3. Feature branches such as `features/html` and `features/router` are purely for experimentation purpose to try out a feature

Installation
------------

[](#installation)

Make sure PHP 5.3.2 or above (at least 5.3.4 recommended to avoid potential bugs) is available on your server

### 1. Install Composer

[](#1-install-composer)

Restler uses [Composer](http://getcomposer.org/) to manage its dependencies. First, download a copy of `composer.phar`. It can be kept in your project folder or ideally in `usr/local/bin` to use it globally for all your projects. If you are on Windows, you can use the composer [windows installer](https://getcomposer.org/Composer-Setup.exe) instead.

### 2. Install Restler

[](#2-install-restler)

#### Option 1. Using composer create-project

[](#option-1-using-composer-create-project)

You may install Restler by running the create project command in your terminal. Replace {projectName} with your actual project name. It will create a folder with that name and install Restler.

```
php composer.phar create-project luracast/restler {projectName}
```

> **Note:-**
>
> 1. If you do not want the additional formats and BDD tools you can include `--no-dev` to enforce exclusion of dev packages.
> 2. If you want to try the bleading edge v3 branch or any of the feature branches include `3.x-dev` or `dev-features/html` in the above command

#### Option 2. Downloading from github

[](#option-2-downloading-from-github)

Once Composer is installed, download the latest version of the Restler framework and extract its contents into a directory on your server. Next, in the root of your Restler project, run the `php composer.phar install`(or `composer install`) command to install all of the framework's dependencies. This process requires Git to be installed on the server to successfully complete the installation.

If you want to update the Restler framework, you may issue the `php composer.phar update` command.

> **Note:-** If are not allowed to install composer and git on your server, you can install and run them on your development machine. The resulting files and folders can be uploaded and used on the server.

### 3. Configure

[](#3-configure)

Ideally public folder should be mapped as your web root, It is optional, but recommended to avoid exposing unneeded files and folders.

### 4. Try it out

[](#4-try-it-out)

Try the live examples in your localhost

### 5. Run some test

[](#5-run-some-test)

Update the base\_url specified in `behat.yml` and then try the following command

```
bin/behat
```

This will test the examples against the behaviors expected, for example

```
Feature: Testing CRUD Example
    Scenario: Creating new Author with JSON
        Given that I want to make a new "Author"
        And his "name" is "Chris"
        And his "email" is "chris@world.com"
        And the request is sent as JSON
        When I request "/examples/_007_crud/authors"
        Then the response status code should be 200
        And the response should be JSON
        And the response has a "id" property
```

All set, Happy Restling! :)

Quick Start Guide
-----------------

[](#quick-start-guide)

Once you have got restler installed with the above steps, you can quickly create your application by following these steps

### 1. Write API

[](#1-write-api)

Create your **API classes** with all needed public and protected methods

### 2. Open the Gateway

[](#2-open-the-gateway)

Create the **gateway (index.php)** as follows

```
