connect()); } catch (Exception $e) { $response->error($e->getMessage(), 500); } // Connect to the database, and ensure the connection is successful try { $db->connect(); } catch (Exception $e) { $response->error($e->getMessage(), 500); } // Load all the traits foreach ( glob(WD . '/traits/*.php') as $trait ) { require_once $trait; } // Load all the routes foreach ( glob(WD . '/routes/*.php') as $route ) { require_once $route; } /** Load all Objects */ foreach ( glob(WD . '/objects/*.php') as $object ) { try { require_once $object; } catch (Exception $e) { $response->error($e->getMessage(), 500); } } // If the program was called from the command line, run the cli script if (php_sapi_name() === 'cli' || isset($_GET['internalCronCall'])) { require_once 'cli.php'; exit; } // Autoload all the routes $router->auto_load_routes(WD . '/routes'); /** If no matching route is found, return a 404 */ if (!$response->is_matching_route_found()) { // Debug $response->add_debug(['message' => 'No matching route found']); $response->not_found(); }