Remote code execution server - this library uses Guzwrap to deconstruct sent
request, perform it, and then send back request response to
RCE Client.
This library act like slave, except that it only support Guzwrap request objects at
the moment.
This project is currently receiving massive updates, which may include code refactoring, namespace change, and many
other stuffs that may cause the code to brake or not work entirely.
This project is not ready!!!
composer require remcodex/server
use Remcodex\Server\Command;
use Remcodex\Server\ErrorHandler;
use Remcodex\Server\Prebuilt\RequestListener;
use Remcodex\Server\Prebuilt\ResponseListener;
use Remcodex\Server\Router;
use Remcodex\Server\Server;
require 'vendor/autoload.php';
//Load http routes
$collector = Router::load(__DIR__ . '/routes.php');
//Load request commands
$commands = Command::load(__DIR__ . '/commands.php');
//Create and start server
Server::create()
->setEnvironment(Server::ENV_DEVELOPMENT)
->setErrorHandler(new ErrorHandler())
->setRouteCollector($collector)
->setCommands($commands)
->onRequest(new RequestListener())
->onResponse(new ResponseListener())
->run();
- App Events
use Remcodex\Server\Events\AppEvent;
AppEvent::onError(function (Throwable $exception){
echo "Error: {$exception->getMessage()} \n";
});
- Http Events
use Psr\Http\Message\ServerRequestInterface;
use QuickRoute\Route\DispatchResult;
use Remcodex\Server\Events\HttpEvent;
use Remcodex\Server\Response\ResponseInterface;
HttpEvent::onRequest(function (ServerRequestInterface $request){
echo "Request received: [{$request->getMethod()}] {$request->getUri()} \n";
});
HttpEvent::onDispatch(function (DispatchResult $dispatchResult){
echo "Route dispatched: {$dispatchResult->getRoute()->getPrefix()} \n";
});
HttpEvent::onResponse(function (ResponseInterface $response){
echo "Response about to be sent: {$response->getStatusCode()} \n";
});