HTTP Client and Server abstraction for PHP.
Warning
This project is not finished yet, work in progress.
You can install the package via composer:
composer require ghostwriter/http
$router = new Router();
$router->addRoute('GET', '/', HomeHandler::class, [GuestMiddleware::class]);
$router->get('/about', AboutHandler::class, [GuestMiddleware::class]);
$router->get('/auth/github', GitHubLoginHandler::class, [GuestMiddleware::class], 'auth.login.github');
// create, read, edit, update, store, delete, view, show
$router->middleware([GuestMiddleware::class], function($router){
$router->get('/auth/login', LoginCreateHandler::class, 'auth.login.create');
$router->post('/auth/login', LoginStoreHandler::class, 'auth.login.store');
$router->get('/auth/register', RegisterCreateHandler::class, 'auth.register.create');
$router->post('/auth/register', RegisterStoreHandler::class, 'auth.register.store');
$router->get('/posts', PostIndexHandler::class, 'members.index');
$router->get('/posts/{post:id}', PostShowHandler::class, 'members.show');
});
$router->middleware([AuthMiddleware::class], function($router){
$router->get('/users', MembersIndexHandler::class, 'members.index');
$router->get('/users/{member:id}', MemberShowHandler::class, 'members.show');
$router->get('/posts/create', PostCreateHandler::class, 'members.create');
$router->post('/posts', PostStoreHandler::class, 'members.store');
$router->get('/posts/{post:id}/edit', PostEditHandler::class, 'members.edit');
$router->put('/posts/{post:id}', PostUpdateHandler::class, 'members.update');
$router->delete('/posts/{post:id}', PostDeleteHandler::class, 'members.delete');
});
$request = new ServerRequest();
$server = new Server($router); // RequestHandler
$server->handle($request); // Response
Please see CHANGELOG.md for more information what has changed recently.
If you discover any security related issues, please email nathanael.esayeas@protonmail.com
or create a Security Advisory instead of using the issue tracker.
The BSD-3-Clause. Please see License File for more information.