1. Go to this page and download the library: Download profmugomes/miphantroute 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/ */
profmugomes / miphantroute example snippets
use MiPhantRoute\MiPhantRoute;
$route = new MiPhantRoute();
$route->getPart('/', function () {
echo 'Página inicial';
});
$route->getPart('/contato', function () {
echo 'Página de contato';
});
$route->getError(function () {
http_response_code(404);
echo '404 - Página não encontrada';
});
[
'/blog/post/123',
['blog', 'post', '123']
]
$route->getPart('/blog', function () {
echo 'Página do blog';
});
$route->getPart('/blog/post/([0-9]+)', function ($id) {
echo "Post ID: {$id}";
});