1. Go to this page and download the library: Download miskynscze/freerouter 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/ */
miskynscze / freerouter example snippets
#[Controller]
class ClassController implements IRouter {
#[Request("/")]
#[Method(RequestMethod::GET)]
public function home(): string {
return "Hello, world!";
}
}
//Getting RouterConfig
$config = new RouterConfig();
$router = new RouterWrapper();
//Running RouterWrapper
$router->config($config)->run(new ClassController());
#[Controller]
class ClassController implements IRouter {
#[Request("/page/{id}")]
#[Method(RequestMethod::GET)]
public function page(string $id): string {
return "You are on page ($id)";
}
}
#[RestController]
class ClassController implements IRouter {
#[Request("/user/{id}")]
#[Method(RequestMethod::GET)]
public function user(string $id): string {
return [
"id" => $id,
"name" => "Test"
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.