working out page routing

This commit is contained in:
Ro 2021-02-28 17:04:54 -08:00
parent 3617565210
commit e459366c46
4 changed files with 77 additions and 48 deletions

View file

@ -1,22 +1,26 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }}</title> <title>{{ title }}</title>
</head> </head>
<body> <body>
<p> <p>
{{ name }} is a {{ occupation }} {{ name }}
is a
{{ occupation }}
</p> </p>
<br> <br>
<div> <div>
{{folks}} has {{ secret }} {{ folks }}
has
{{ secret }}
</div> </div>
</body> </body>
</html> </html>

View file

@ -1,33 +0,0 @@
<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
use Slim\Views\Twig;
use Slim\Views\TwigMiddleware;
include 'brain/controller/IndexControl.inc.php';
include 'brain/data/Settings.inc.php';
require __DIR__ . '/vendor/autoload.php';
$app = AppFactory::create();
$twig = Twig::create('brain/views/default/');
$app->add(TwigMiddleware::create($app, $twig));
//Dashboard Index
$app->get('/dashboard', function (Request $request, Response $response) {
$index = new IndexControl();
$settings = new Settings();
$folks = $settings->getFolks();
$secret = $index->getSecret();
$view = Twig::fromRequest($request);
return $view->render($response, 'index.twig', [
'title' => 'This is Fipamo',
'name' => 'Ro',
'occupation'=>'pretty cool... I guess',
'folks' => $folks[0]['handle'],
'secret' => $secret
]);
});
$app->run();

View file

@ -1 +0,0 @@
This is the index

59
index.php Normal file
View file

@ -0,0 +1,59 @@
<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
use Slim\Views\Twig;
use Slim\Views\TwigMiddleware;
include 'brain/controller/IndexControl.inc.php';
include 'brain/data/Settings.inc.php';
require __DIR__ . '/vendor/autoload.php';
$app = AppFactory::create();
$twig = Twig::create('brain/views/default/');
$app->add(TwigMiddleware::create($app, $twig));
//Index
$app->get('/[{first}[/{second}]]', function (Request $request, Response $response, array $args) {
if(isset($args['first']))
{
$first = $args['first'];
if(is_numeric($first))
{
$response->getBody()->write("FIND A PAGE, B!");
}else{
$response->getBody()->write("This is the dash, brah!");
};
}else{
$response->getBody()->write("No Params, Homie!");
}
if(isset($args['second']))
{
$year = $args['second'];
};
return $response;
});
//Dashboard Index
/**
$app->get('/@/dashboard', function (Request $request, Response $response) {
$index = new IndexControl();
$settings = new Settings();
$folks = $settings->getFolks();
$secret = $index->getSecret();
$view = Twig::fromRequest($request);
return $view->render($response, 'index.twig', [
'title' => 'This is Fipamo',
'name' => 'Ro',
'occupation'=>'pretty cool... I guess',
'folks' => $folks[0]['handle'],
'secret' => $secret
]);
});
**/
$app->run();