ghostwriter / http
HTTP Client and Server abstraction for PHP.
Maintainers
Details
Fund package maintenance!
ghostwriter
Installs: 51 788
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 5
Requires
- php: >=8.3
- ext-curl: *
- ext-json: *
- ext-mbstring: *
Requires (Dev)
- ghostwriter/coding-standard: dev-main
- ghostwriter/psalm-plugin: ^0.2.0
This package is auto-updated.
Last update: 2024-12-06 16:16:42 UTC
README
HTTP Client and Server abstraction for PHP.
Warning
This project is not finished yet, work in progress.
Installation
You can install the package via composer:
composer require ghostwriter/http
Usage
$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
Changelog
Please see CHANGELOG.md for more information what has changed recently.
Security
If you discover any security related issues, please email nathanael.esayeas@protonmail.com
or create a Security Advisory instead of using the issue tracker.
License
The BSD-3-Clause. Please see License File for more information.