PHP code example of marco476 / routing-manager
1. Go to this page and download the library: Download marco476/routing-manager 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/ */
marco476 / routing-manager example snippets
outing\Routing;
$Routing = new Routing();
$Routing->setRoutes(array(
'homepage' => array( //Name route
'expression' => '/', //MUST DEFINE!
'controller'=> 'MyController',
'action' => 'MyAction',
'extra1' => 'extra1',
'extra2' => 'extra2'
)
));
if ($routeMatch = $Routing->matchRoute()) {
echo "See that" . "<br>";
var_dump($routeMatch);
} else {
echo "mmm.. what's wrong?";
}
outing\Routing;
$Routing = new Routing();
$Routing->setRoutesFromYml(__DIR__, 'routes.yml');
if ($routeMatch = $Routing->matchRoute()) {
echo "See that" . "<br>";
var_dump($routeMatch);
} else {
echo "mmm.. what's wrong?";
}
outing\Routing;
$Routing = new Routing();
$Routing->setRoutesFromXml(__DIR__, 'routes.xml');
if ($routeMatch = $Routing->matchRoute()) {
echo "See that" . "<br>";
var_dump($routeMatch);
} else {
echo "mmm.. what's wrong?";
}
'expression' => '/{myName}'
'expression' => '/{myName}',
'::STRING
)
'expression' => '/{myName}',
' )
//Into web/index.php.
$Routing = new Routing();
$Routing->setRoutes(array(
'homepage' => array(
'expression' => '/{wildcard}/{wildcard2}',
' => 'MyAction',
'extra1' => 'extra1',
)
));
if ($routeMatch = $Routing->matchRoute()) {
echo "See my data!";
var_dump($routeMatch);
} else {
echo "mmm.. what's wrong?";
}