1. Go to this page and download the library: Download selami/router library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
selami / router example snippets
declare(strict_types=1);
$request = new PSR7ServerRequest(); // Let's say this class implements PSR7 ServerRequestInterface
$response = new PSR7ServerResponse(); // Let's say this class implements PSR7 ResponseInterface
$defaultReturnType = Selami\Router\Router::JSON; // Possible values: Selami\Router\Router::HTML, Selami\Router\Router::JSON, Selami\Router::TEXT, Selami\Router\Router::CUSTOM, Selami\Router\Router::REDIRECT, Selami\Router::DOWNLOAD. To be used to send output.
$requestMethod = 'GET'; // i.e. $_SERVER['REQUEST_METHOD']
$requestedUri = '/user/12/inbox'; // i.e. $_SERVER['REQUEST_URI']
$router = new Selami\Router(
$defaultReturnType,
$requestMethod,
$requestedUri
);
declare(strict_types=1);
namespace Controller\Api\Users;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use BaseController;
class Inbox extends BaseController {
private $uriParameters;
public function __construct($uriParameters)
{
parent::__construct();
$this->uriParameters = $uriParameters;
}
public function returnHTML(ServerRequestInterface $request, ResponseInterface $response)
{
$response = $this->response->withHeader('Content-Type', 'text/html');
$response->getBody()->write('Your user id is: ' . $this->args['id'] . '. You are viewing your '. $this->uriParameters['box']);
return $response->output();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.