From f74b52cab8fab1673fdd218709c9544ccd2c351a Mon Sep 17 00:00:00 2001 From: mr-phlames Date: Thu, 17 Oct 2019 18:45:45 +0000 Subject: [PATCH] restructured project to match composer --- html/home.php | 12 ----- routes/index.php | 52 ------------------- src/config/init.php | 22 -------- src/core/{auth.php => authentication.php} | 0 src/core/{date.php => customdate.php} | 0 src/core/{router.php => leaf.php} | 2 +- src/core/{respond.php => response.php} | 0 .../{fieldValidate.php => validation.php} | 0 8 files changed, 1 insertion(+), 87 deletions(-) delete mode 100644 html/home.php delete mode 100644 routes/index.php delete mode 100644 src/config/init.php rename src/core/{auth.php => authentication.php} (100%) rename src/core/{date.php => customdate.php} (100%) rename src/core/{router.php => leaf.php} (99%) rename src/core/{respond.php => response.php} (100%) rename src/core/{fieldValidate.php => validation.php} (100%) diff --git a/html/home.php b/html/home.php deleted file mode 100644 index d566554..0000000 --- a/html/home.php +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - Home - - -

This is the homepage

- - \ No newline at end of file diff --git a/routes/index.php b/routes/index.php deleted file mode 100644 index 85719e3..0000000 --- a/routes/index.php +++ /dev/null @@ -1,52 +0,0 @@ -set404(function () { - header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); - echo '404, route not found!'; - }); - - $leaf->get('/', function() use($response) { - $res = [ - 'message' => 'Welcome to the Leaf PHP starter...you can find a simple demo in `routes/index.php`', - 'first steps' => array( - 'One' => 'Define what you want to use Leaf Starter for (setting up an API or server side rendering is especially easy with Leaf)', - 'Two' => 'Read the documentation, every piece of functionality you need has been explained over there' - ) - ]; - echo $response->respond($res); - }); - - $leaf->get('/home', function() use($response) { - // there's no need to return the html page since it will display immedietly it loads - $response->renderHtmlPage('html/home.php'); - }); - - $leaf->get('/hello', function () { - echo '

bramus/router

Visit /hello/name to get your Hello World mojo on!

'; - }); - - $leaf->get('/user/{id}', function ($id) { - echo $id; - }); - - // database example (to use, first define your database connection variables in init.php) - // $leaf->get('/books/all', function() use($connection, $response) { - // $books = mysqli_fetch_all(mysqli_query($connection, "SELECT * FROM books")); - // echo $response->respond($books); - // }); - - $leaf->get('/date-tests', function() use($response, $date) { - // some date methods - $timestamp = $date->timestamp(); - $dates = array(); - $dates['GetDateFromTimeStamp'] = $date->GetDateFromTimeStamp($timestamp); - $dates['GetEnglishDateFromTimeStamp'] = $date->GetEnglishDateFromTimeStamp($timestamp); - $dates['GetEnglishTimeStampFromTimeStamp'] = $date->GetEnglishTimeStampFromTimeStamp($timestamp); - $dates['GetTimeFromTimeStamp'] = $date->GetTimeFromTimeStamp($timestamp); - echo $response->respond($dates); - }); - - $leaf->get('/token/create', function() use($authentication, $response) { - $token = $authentication->generateSimpleToken(1, "SECRET KEY"); - echo $response->respond(["token" => $token]); - }); diff --git a/src/config/init.php b/src/config/init.php deleted file mode 100644 index bd26360..0000000 --- a/src/config/init.php +++ /dev/null @@ -1,22 +0,0 @@ -connectMysqli($host, $user, $password, $dbname); - - $leaf = new \Leaf\Core\Router(); - - $response = new \Leaf\Core\Response(); - - $request = new \Leaf\Core\Request(); - - $validate = new \Leaf\Core\Validation($response); - - $date = new \Leaf\Core\CustomDate(); - - $jwt = new \Leaf\Helpers\JWT(); - - $authentication = new \Leaf\Core\Authentication(); diff --git a/src/core/auth.php b/src/core/authentication.php similarity index 100% rename from src/core/auth.php rename to src/core/authentication.php diff --git a/src/core/date.php b/src/core/customdate.php similarity index 100% rename from src/core/date.php rename to src/core/customdate.php diff --git a/src/core/router.php b/src/core/leaf.php similarity index 99% rename from src/core/router.php rename to src/core/leaf.php index cc5ad4a..dbe0c55 100644 --- a/src/core/router.php +++ b/src/core/leaf.php @@ -4,7 +4,7 @@ */ namespace Leaf\Core; - class Router + class Leaf { /** * @var array The route patterns and their handling functions diff --git a/src/core/respond.php b/src/core/response.php similarity index 100% rename from src/core/respond.php rename to src/core/response.php diff --git a/src/core/fieldValidate.php b/src/core/validation.php similarity index 100% rename from src/core/fieldValidate.php rename to src/core/validation.php