summaryrefslogtreecommitdiff
path: root/app.php
diff options
context:
space:
mode:
Diffstat (limited to 'app.php')
-rw-r--r--app.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/app.php b/app.php
new file mode 100644
index 0000000..45ac885
--- /dev/null
+++ b/app.php
@@ -0,0 +1,29 @@
+<?php
+
+require __DIR__ . '/vendor/autoload.php';
+
+$loader = new \Twig\Loader\FilesystemLoader(__DIR__ . '/views');
+$twig = new \Twig\Environment($loader); # no cache
+
+$function = new \Twig\TwigFunction('is_active', function($route) {
+ $url = strtok($_SERVER["REQUEST_URI"], '?');
+ if ( str_starts_with($url, $route) ) {
+ echo " active ";
+ }
+});
+$twig->addFunction($function);
+
+$function = new \Twig\TwigFunction('maincss', function() {
+ echo readfile(__DIR__ . '/public/css/bootstrap.min.css');
+});
+$twig->addFunction($function);
+
+/**
+ * Debug
+ */
+$function = new \Twig\TwigFunction('dump', function($data) {
+ var_dump($data);
+});
+$twig->addFunction($function);
+
+require __DIR__ . '/db.php';