mirror of
https://github.com/restoreddev/phpapprentice.git
synced 2025-10-28 20:35:45 +01:00
Initial commit for public repo
This commit is contained in:
27
src/util/router.php
Normal file
27
src/util/router.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Router file used for development server
|
||||
* to create html files on demand
|
||||
*/
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
load_config(__DIR__ . '/../../config.php');
|
||||
|
||||
$uri = $_SERVER['REQUEST_URI'];
|
||||
$pathinfo = pathinfo($uri);
|
||||
|
||||
if ($pathinfo['dirname'] == '/' && !isset($pathinfo['extension'])) {
|
||||
$pathinfo['extension'] = 'html';
|
||||
$pathinfo['filename'] = 'index';
|
||||
}
|
||||
|
||||
if ($pathinfo['extension'] == 'html') {
|
||||
$build = new Apprentice\Build;
|
||||
$output = $build->runSingleBuild($pathinfo['filename']);
|
||||
|
||||
echo $output;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
Reference in New Issue
Block a user