This example below using ReflectionMethod class (my self version):
PHP Code:
<?php
$router = Config\Services::router();
$className = $router->controllerName();
$methodName = $router->methodName();
$params = $router->params();
$method = new ReflectionMethod($className, $methodName);
foreach( $method->getParameters() as $key => $param )
{
$value = isset($params[$key]) ? $params[$key] : 'null'; // 'null' or $param->getDefaultValue()
echo '$' . $param->getName() . ' => ' . $value . '<br>'; // or using table
}
PHP: 7.0.5
Controller:
PHP Code:
<?php namespace App\Controllers;
class Products extends CodeIgniter\Controller {
public function shoes($brand, $id)
{
echo $brand;
echo $id;
}
}
URL:
Code:
example.com/products/shoes/penguin/13
Before (Debug Bar):
Code:
Routes
Matched Route
Directory :
Controller : Products
Method : shoes
Params : array(
[0] => penguin
[1] => 13
)
Expected output (Debug Bar):
Code:
Routes
Matched Route
Directory :
Controller : Products
Method : shoes
Params : $brand => penguin
$id => 13