Browse Source

initial twig

master
Lennart Verschelden 2 years ago
parent
commit
2c941e8507
3 changed files with 8 additions and 2 deletions
  1. 1
    1
      composer.json
  2. 7
    1
      public/index.php
  3. 0
    0
      templates/clientcreate.html.twig

+ 1
- 1
composer.json View File

@@ -13,4 +13,4 @@
"Shop\\": "src/"
}
}
}
}

+ 7
- 1
public/index.php View File

@@ -4,7 +4,6 @@ namespace Shop;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
use Shop\DB\DB;
use Shop\DB\Client;
use Shop\DB\Order_lines;
use Shop\DB\Products;
@@ -16,10 +15,17 @@ require __DIR__ . '/../vendor/autoload.php';

$app = AppFactory::create();

$loader = new \Twig\Loader\FilesystemLoader('../templates');
$twig = new \Twig\Environment($loader, );

$app->map(['GET', 'POST'], "/orders/{client}/create", function (Request $request, Response $response, array $args) {
$db2 = new Client();
$client = $args['client'];
$a = $db2->getClientName($client);
global $twig;
$template = $twig->load('clientcreate.html.twig');
$b = $template->render();
$response->getBody()->write($b);
if ($request->getMethod() == "GET") {
$response->getBody()->write("<h1>Create order for" . $a['firstname'] . " " . $a['lastname'] . "</h1><hr/>");
$response->getBody()->write('<form action="/orders/' . $args['client'] . '/create" method="post">');

+ 0
- 0
templates/clientcreate.html.twig View File


Loading…
Cancel
Save