diff --git a/README.md b/README.md index 821ecdf..3f185db 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,20 @@ -# novaconium +![Novaconium PHP](/_assets/header.svg) -4LT's PHP framework \ No newline at end of file +# Novaconium PHP: A PHP Framework Built from the Past + +NovaconiumPHP is a high-performance PHP framework designed with inspiration from classic coding principles. + +Pronounced: Noh-vah-koh-nee-um + +## Getting Started + +### Installation + +```bash +mkdir project_name; +cd project_name; +mkdir -p App/controllers App/templates App/views public +touch App/controllers/404.php App/controllers/index.php App/views/index.html.twig public/index.php public/.htaccess App/routes.php + +composer require 4lt/novaconium +``` diff --git a/_assets/header.svg b/_assets/header.svg new file mode 100644 index 0000000..1324924 --- /dev/null +++ b/_assets/header.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Novaconium PHP + + \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..8b11c5d --- /dev/null +++ b/composer.json @@ -0,0 +1,29 @@ +{ + "name": "4lt/novaconium", + "description": "A high-performance PHP framework built from the past.", + "version": "1.0.0", + "license": "MIT", + "authors": [ + { + "name": "Nick Yeoman", + "email": "dev@4lt.ca", + "homepage": "https://www.4lt.ca", + "role": "Consultant" + } + ], + "autoload": { + "psr-4": { + "Novaconium\\\\": "src/" + } + }, + "require": { + "twig/twig": "*", + }, + "minimum-stability": "stable", + "extra": { + "versioning": { + "strategy": "semantic-versioning" + } + } +} + \ No newline at end of file diff --git a/src/Router.php b/src/Router.php new file mode 100644 index 0000000..6bde1a7 --- /dev/null +++ b/src/Router.php @@ -0,0 +1,43 @@ +loadRoutes(); + $this->preparePath(); + $this->prepareQuery(); + $this->setRouteFile(); + } + + private function loadRoutes() { + require_once( BASEPATH . '/App/routes.php'); + $this->routes = $routes; + } + + private function preparePath() { + $this->path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); + } + + private function prepareQuery() { + $parsedUri = parse_url($_SERVER['REQUEST_URI']); + $queryArray = []; + if (isset($parsedUri['query'])) { + parse_str($parsedUri['query'], $queryArray); + } + $this->query = $queryArray; + } + + private function setRouteFile() { + foreach ($this->routes as $key => $value) { + if ( $this->path == $key) { + $this->controllerPath = BASEPATH . '/App/controllers/' . $value['file'] . '.php'; + break; + } + } + } + +} \ No newline at end of file diff --git a/src/bootstrap.php b/src/bootstrap.php new file mode 100644 index 0000000..99322d7 --- /dev/null +++ b/src/bootstrap.php @@ -0,0 +1,13 @@ +addPath(BASEPATH . '/vendor/nickyeoman/nytwig/src', 'nytwig'); +$loader->addPath(BASEPATH . '/App/templates', 'override'); +$twig = new Twig\Environment($loader); + +// Load a controller +require_once('Router.php'); +$router = new Router(); +require_once($router->controllerPath); \ No newline at end of file