Simple PHP Library for RESTful APIs
Go to file
PJ Dietz 2adcbd8636 Remove Router and rename RouteMap to Router
Remove Router
Remove RouterInterface
Rename RouteMapInterface to RouterInterface
Rename RouteMap to Router
Rename add() to register()
Make register fluid
2015-05-10 09:05:05 -04:00
docs Add reStructuredText documentation 2015-03-16 20:09:53 -04:00
src Remove Router and rename RouteMap to Router 2015-05-10 09:05:05 -04:00
test Remove Router and rename RouteMap to Router 2015-05-10 09:05:05 -04:00
vagrant Add home page to test site. Add autoload sandbox directory. 2015-03-11 21:34:20 -04:00
.gitignore Add reStructuredText documentation 2015-03-16 20:09:53 -04:00
.travis.yml Update README. Add PHP 5.6 to Travis. 2015-01-21 12:56:55 -05:00
README.md Update README.md with link to Read the Docs. 2015-03-16 20:32:08 -04:00
Vagrantfile Read Vagrant host port from environment variable. 2015-03-11 15:36:49 -04:00
composer.json Add Composer alias for psr/http-message fork. 2015-04-29 07:21:29 -04:00
composer.lock Add Composer alias for psr/http-message fork. 2015-04-29 07:21:29 -04:00
phpunit.xml.dist Update composer, phpunit configuration, and remove apache_request_headers 2015-04-16 19:02:43 -04:00

README.md

WellRESTed

Build Status

WellRESTed is a micro-framework for creating RESTful APIs in PHP. It provides a lightweight yet powerful routing system and classes to make working with HTTP requests and responses clean and easy.

Requirements

  • PHP 5.3
  • PHP cURL for making requests with the Client class (Optional)

Install

Add an entry for "pjdietz/wellrested" to your composer.json file's require property. If you are not already using Composer, create a file in your project called "composer.json" with the following content:

{
    "require": {
        "pjdietz/wellrested": "~2.3"
    }
}

Use Composer to download and install WellRESTed. Run these commands from the directory containing the composer.json file.

$ curl -s https://getcomposer.org/installer | php
$ php composer.phar install

You can now use WellRESTed by including the vendor/autoload.php file generated by Composer.

Overview

WellRESTed's primary goal is to facilitate mapping of URIs to classes that will provide or accept representations. To do this, create a Router instance and load it up with some routes.

use pjdietz\WellRESTed\Response;
use pjdietz\WellRESTed\Router;

require_once "vendor/autoload.php";

// Create a new router.
$router = new Router();

// Populate the router with routes.
$router->add(
    ["/", "\\MyApi\\RootHandler"],
    ["/cats/", "\\MyApi\\CatHandler"],
    ["/dogs/*", "\\MyApi\\DogHandler"],
    ["/guinea-pigs/{id}", "\\MyApi\\GuineaPigHandler"],
    ["~/hamsters/([0-9]+)~", "\\MyApi\\HamsterHandler"]
);

// Output a response based on the request sent to the server.
$router->respond();

Documentation

See the documentation to get started.

Copyright © 2015 by PJ Dietz Licensed under the MIT license