// Routes
$routes->get('/products/(:num)/(:any)', 'Product::oneSegment/$1/$2');
$routes->get('/products/(:num)', 'Product::oneSegment/$1');
// Controller
class Product extends BaseController
{
/**
* @see http://localhost:8080/products/111
* @see http://localhost:8080/products/111/adaw/adawd/awdawdeg/
*/
public function oneSegment($segment1, ...$segments)
{
return response()->setBody('Product::oneSegment with ' . $segment1 . ' and ' . implode(', ', $segments) . ' loaded');
}
}
// Output
Product::oneSegment with 111 and loaded
Product::oneSegment with 111 and awdaw, adawd loaded