Created: 2012-08-21 00:34
Updated: 2018-12-18 02:02



Build Status Documentation Status SensioLabsInsight

WellRESTed is a library for creating RESTful Web services and websites in PHP.


  • PHP 7.0


Add an entry for "wellrested/wellrested" to your composer.json file's require property.

    "require": {
        "wellrested/wellrested": "~3.1"


See the documentation to get started.



use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use WellRESTed\Message\Response;
use WellRESTed\Message\Stream;
use WellRESTed\Server;

// Create a handler using the PSR-15 RequestHandlerInterface
class HomePageHandler implements RequestHandlerInterface
    public function handle(ServerRequestInterface $request): ResponseInterface
        // Create and return new Response object to return with status code,
        // headers, and body.
        $response = (new Response(200))
            ->withHeader('Content-type', 'text/html')
            ->withBody(new Stream('<h1>Hello, world!</h1>'));
        return $response;

// -----------------------------------------------------------------------------

// Create a new server.
$server = new Server();

// Add a router to the server to map methods and endpoints to handlers.
$router = $server->createRouter();
$router->register('GET', '/', new HomePageHandler());

// Read the request from the client, dispatch a handler, and output.


Use Docker to run unit tests, manage Composer dependencies, and render a preview of the documentation site.

To get started, run:

docker-compose build
docker-compose run --rm php composer install

To run PHPUnit tests, use the php service:

docker-compose run --rm php phpunit

To generate documentation, use the docs service:

# Generate
docker-compose run --rm docs
# Clean
docker-compose run --rm docs make clean -C docs

To run a local playground site, use:

docker-compose up -d

The runs a site you can access at http://localhost:8080. You can use this site to browser the documentation or code coverage report.

Copyright and License

Copyright © 2018 by PJ Dietz Licensed under the MIT license

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more