updated defaults from examples

This commit is contained in:
Nick Yeoman 2024-09-27 12:58:19 -07:00
parent 7cd3071905
commit 0d4b62ffb9
10 changed files with 37 additions and 8 deletions

11
defaults/App/config.php Normal file
View File

@ -0,0 +1,11 @@
<?php
$config = [
'database' => [
'host' => '',
'name' => '',
'user' => '',
'pass' => '',
'port' => 3306
],
'base_url' => 'http://localhost:8000'
];

View File

@ -11,4 +11,5 @@ header("Content-Type: text/html");
<h1>Error 404 Resource Not found</h1> <h1>Error 404 Resource Not found</h1>
<p><?php echo $status_message; ?></p> <p><?php echo $status_message; ?></p>
<p style="font-size:10px; margin-top:60px">Novaconium Default 404 page.</p>

View File

@ -19,7 +19,12 @@ class Router {
} }
private function loadRoutes() { private function loadRoutes() {
require_once( BASEPATH . '/App/routes.php'); // Check if Path exists
if (file_exists(BASEPATH . '/App/routes.php')) {
require_once( BASEPATH . '/App/routes.php');
} else {
require_once(FRAMEWORKPATH . '/defaults/App/routes.php');
}
return $routes; return $routes;
} }
@ -104,9 +109,13 @@ class Router {
if (file_exists($cp)) { if (file_exists($cp)) {
return $cp; return $cp;
} else { } else {
return BASEPATH . '/App/controllers/404.php'; //Check if 404 exits
if (file_exists(BASEPATH . '/App/controllers/404.php')) {
return BASEPATH . '/App/controllers/404.php';
} else {
return FRAMEWORKPATH . '/defaults/App/controllers/404.php';
}
} }
} }
public function debug() { public function debug() {

View File

@ -1,20 +1,28 @@
<?php <?php
define('FRAMEWORKPATH', BASEPATH . '/vendor/4lt/novaconium');
require_once(BASEPATH . '/vendor/autoload.php'); require_once(BASEPATH . '/vendor/autoload.php');
require_once(BASEPATH . '/App/config.php');
//Check if config file exists
if (file_exists(BASEPATH . '/App/config.php')) {
require_once(BASEPATH . '/App/config.php');
} else {
require_once(FRAMEWORKPATH . '/defaults/App/config.php');
}
// Creates twig and the view() function // Creates twig and the view() function
require_once(BASEPATH . '/vendor/4lt/novaconium/src/twig.php'); require_once(FRAMEWORKPATH . '/src/twig.php');
// Start a Session // Start a Session
require_once(BASEPATH . '/vendor/4lt/novaconium/src/Session.php'); require_once(FRAMEWORKPATH . '/src/Session.php');
$session = new Session(); $session = new Session();
// Load Database Class // Load Database Class
require_once(BASEPATH . '/vendor/4lt/novaconium/src/Database.php'); require_once(FRAMEWORKPATH . '/src/Database.php');
$db = new Database($config['database']); $db = new Database($config['database']);
// Load a controller // Load a controller
require_once(BASEPATH . '/vendor/4lt/novaconium/src/Router.php'); require_once(FRAMEWORKPATH . '/src/Router.php');
$router = new Router(); $router = new Router();
//$router->debug(); //$router->debug();
require_once($router->controllerPath); require_once($router->controllerPath);