PHP code example of entrydo / rest-route

1. Go to this page and download the library: Download entrydo/rest-route 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/ */

    

entrydo / rest-route example snippets


use Entrydo\RestRoute\Route;
use Nette\Application\Routers\RouteList;

$router = new RouteList();

$router[] = new Route('/', HomepagePresenter::class);

$router[] = RestRoute::get('/', HomepagePresenter::class);
// or
$router[] = new Route('/', HomepagePresenter::class, [IRequest::GET]);

$router[] = new RestRoute::post('/', HomepagePresenter::class);
// or
$router[] = new Route('/', HomepagePresenter::class, [IRequest::POST]);

$router[] = new RestRoute::put('/', HomepagePresenter::class);
// or
$router[] = new Route('/', HomepagePresenter::class, [IRequest::PUT]);

$router[] = new RestRoute::delete('/', HomepagePresenter::class);
// or
$router[] = new Route('/', HomepagePresenter::class, [IRequest::DELETE]);

$router[] = new RestRoute::patch('/', HomepagePresenter::class);
// or
$router[] = new Route('/', HomepagePresenter::class, [IRequest::PATCH]);

$router[] = new RestRoute::head('/', HomepagePresenter::class);
// or
$router[] = new Route('/', HomepagePresenter::class, [IRequest::HEAD]);

$router[] = new RestRoute::options('/', HomepagePresenter::class);
// or
$router[] = new Route('/', HomepagePresenter::class, [IRequest::OPTIONS]);

$router[] = new Route('/', HomepagePresenter::class, [IRequest::GET, IRequest::POST, IRequest::DELETE]);