PHP code example of marko / routing
1. Go to this page and download the library: Download marko/routing 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/ */
marko / routing example snippets
use Marko\Routing\Attributes\Get;
use Marko\Routing\Attributes\Post;
use Marko\Routing\Http\Response;
class ProductController
{
#[Get('/products')]
public function index(): Response
{
return new Response('Product list');
}
#[Get('/products/{id}')]
public function show(int $id): Response
{
return new Response("Product $id");
}
#[Post('/products')]
public function store(): Response
{
return new Response('Created', 201);
}
}