PHP code example of meowphp / routing

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

    

meowphp / routing example snippets


/**
 * Register your application's controller here
*/
$controllers => [
    \May\AttributesTest\MainController::class,
    \May\AttributesTest\Controllers\ExampleController::class
],

# Route without attributes
#[Route('/hello/{id}/{surname}')]
public function sayHello() : string

# Route with attributes
#[Route("/good-bye")]
public function sayGoodBye() : string

# Default route
#[Route('/')]
public function index() : string

$router = \Meow\Routing\Router::getRouter($controllers);

$calledRoute = $this->router->matchFromUri('/your/route');

$calledRoute->getController();
$calledRoute->getMethod();

if ($calledRoute->hasParameters()) {
    $request = $calledRoute->getParameters();
}

#[Prefix('/api')]
class ExampleController extends AppController