-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
123 lines (105 loc) · 3.95 KB
/
index.html
File metadata and controls
123 lines (105 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
---
layout: default
---
<div class="home">
<h1>WellRESTed</h1>
<p>WellRESTed is a library for creating RESTful APIs and websites in PHP
that provides abstraction for HTTP messages, a powerful middleware
system, and a flexible router.</p>
{% highlight php %}
<?php
namespace App;
use DI;
use Psr\Container\ContainerInterface;
use WellRESTed\Server;
require_once 'vendor/autoload.php';
$builder = new DI\ContainerBuilder();
$builder->addDefinitions([
Server::class => function (ContainerInterface $c): Server {
$server = new Server();
$server->add(ErrorMiddleware::class);
$router = $server->createRouter();
$server->addRoute($router);
$router
->register('GET', '/', HomeHandler::class)
->register('GET', '/cats/', CatsListHandler::class)
->register('POST', '/cats/', [
AuthMiddleware::class,
JsonMiddleware::class,
CatCreateHandler::class
])
->register('GET', '/cats/{id}', CatHandler::class)
->register('PUT', '/cats/{id}', [
AuthMiddleware::class,
JsonMiddleware::class,
CatUpdateHandler::class
])
->register('DELETE', '/cats/{id}', [
AuthMiddleware::class,
CatDeleteaHandler::class
]);
return $server;
}
]);
$container = $builder->build();
$server = $container->get(Server::class);
$server->respond();
{% endhighlight %}
<h2>Features</h2>
<div class="row">
<div class="col-sm-6">
<h3>PSR-7</h3>
<p>Requests and responses are built to the interfaces standardized by
<a class="no-break" href="https://www.php-fig.org/psr/psr-7/">PSR-7</a> making it easy to
share code and use components from other libraries and frameworks.</p>
</div>
<div class="col-sm-6">
<h3>PSR-15</h3>
<p>Build your application using handlers and middleware implementing the interfaces defined by <a class="no-break" href="https://www.php-fig.org/psr/psr-15/">PSR-15</a>.
</div>
</div>
<div class="row">
<div class="col-sm-6">
<h3>Router</h3>
<p>Use a <a href="https://wellrested.readthedocs.io/en/latest/router.html">
router</a> to map HTTP methods and paths to hanlders, middleware, or sub-routers.
</div>
<div class="col-sm-6">
<h3>URI Templates</h3>
<p>Use <a href="https://wellrested.readthedocs.io/en/latest/uri-templates.html">URI templates</a>
like <code>/foo/{bar}/{baz}</code>, <code>/list/{items*}</code>, or
<code>{/path*}</code> that match patterns of paths and provide captured
variables.</p>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<h3>Lazy Dispatching</h3>
<p>WellRESTed's dispatcher can delay instantiating handlers until they're
needed, so even large apps can stay light weight.</p>
</div>
<div class="col-sm-6">
<h3>Dependency Injection</h3>
<p>WellRESTed does not supply a DI container, but can work with any
an any <a class="no-break" href="https://www.php-fig.org/psr/psr-11/">PSR-11</a>
container.</p>
</div>
</div>
<h2>Installation</h2>
<p>The recommended method for installing WellRESTed is to use <a href="https://getcomposer.org/">Composer</a>. Add
an entry for WellRESTed in your project’s composer.json file.</p>
{% highlight json %}
{
"require": {
"wellrested/wellrested": "^6"
}
}
{% endhighlight %}
<h2>Requirements</h2>
<ul>
<li>PHP 8.1</li>
</ul>
<h2>Documentation</h2>
<p>The documentaiton for WellRESTed is available at
<a href="https://wellrested.readthedocs.io">https://wellrested.readthedocs.io</a></p>
</div>