https://github.com/remcodex/server
Remote Code Execution Server
https://github.com/remcodex/server
guzwrap guzzlehttp http php rce remcodex remote-execution
Last synced: 3 days ago
JSON representation
Remote Code Execution Server
- Host: GitHub
- URL: https://github.com/remcodex/server
- Owner: remcodex
- Created: 2020-12-31T11:15:10.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-02-15T02:29:03.000Z (about 5 years ago)
- Last Synced: 2025-12-14T22:07:20.027Z (4 months ago)
- Topics: guzwrap, guzzlehttp, http, php, rce, remcodex, remote-execution
- Language: PHP
- Homepage:
- Size: 65.4 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RCE Server
Remote code execution server - this library uses [Guzwrap](https://github.com/Ahmard/guzwrap) to deconstruct sent
request, perform it, and then send back request response to
[RCE Client](https://github.com/remcodex/client).
This library act like slave, except that it only support [Guzwrap](https://github.com/Ahmard/guzwrap) request objects at
the moment.
## Notice 🔊
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!!!**
## Installation
```bash
composer require remcodex/server
```
## Usage
```php
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();
```
### Events
- App Events
```php
use Remcodex\Server\Events\AppEvent;
AppEvent::onError(function (Throwable $exception){
echo "Error: {$exception->getMessage()} \n";
});
```
- Http Events
```php
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";
});
```