1. Go to this page and download the library: Download 4asuite/nano-php 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/ */
namespace App\Controllers;
use App\Core\Controller;
use App\Core\Response;
final class UserController extends Controller
{
public function show(string $id): Response
{
return $this->view('users/show', ['id' => $id]);
}
public function store(): Response
{
$name = $this->request->post('name', '');
// ...
return $this->redirect('/users');
}
public function api(): Response
{
return $this->json(['status' => 'ok']);
}
}