PHP code example of oihana / php-controllers
1. Go to this page and download the library: Download oihana/php-controllers 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/ */
oihana / php-controllers example snippets
use DI\Container;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use oihana\controllers\Controller;
use function oihana\controllers\helpers\getParamInt;
class HelloController extends Controller
{
public function index( ServerRequestInterface $request, ResponseInterface $response, array $args ): ResponseInterface
{
$page = getParamInt( $request, 'page', 1 );
return $this->json( $response, [ 'page' => $page ] );
}
}
bash
composer