$dispatcher = Dispatcher::getInstance(); $dispatcher->addHandler('/home', 'HomeController'); $dispatcher->handle('/home');
$dispatcher = Dispatcher::getInstance(); $dispatcher->addHandler('/products', 'ProductController'); $dispatcher->addHandler('/products/:id', 'ProductDetailController'); $dispatcher->handle('/products/123');In this example, we register two handlers with the dispatcher for the "/products" and "/products/:id" URL paths. The :id part of the second URL path is a placeholder that can match any value. When we call the handle method on the dispatcher instance, passing in "/products/123" as the URL path, the dispatcher will match it to the second handler and pass the value 123 as a parameter to the handler method. Based on the method name and class name, it's likely that the Dispatcher class is part of a package library for routing requests in a PHP web application.