Simple PHP Library for RESTful APIs
Go to file
PJ Dietz 4096295421 Stream can be created with a string as well as resource handle. 2015-04-12 13:10:40 -04:00
docs Add reStructuredText documentation 2015-03-16 20:09:53 -04:00
src Stream can be created with a string as well as resource handle. 2015-04-12 13:10:40 -04:00
test Stream can be created with a string as well as resource handle. 2015-04-12 13:10:40 -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 Move HttpExceptions to new namespace. 2015-03-24 20:32:30 -04:00
composer.lock Update minimum PHP in composer to 5.4 2015-03-22 09:10:46 -04:00
phpdoc.dist.xml Add reStructuredText documentation 2015-03-16 20:09:53 -04:00
phpunit.xml.dist Run tests in strict coverage mode by default 2015-03-22 11:35:23 -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