Skip to content

Commit

Permalink
index.phtml and slim processor
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-xz committed Jun 15, 2024
1 parent 42f4aa9 commit 730bcd5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
10 changes: 8 additions & 2 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
use DI\Container;

require __DIR__ . '/../vendor/autoload.php';

$container = new Container();
$container->set('renderer', function () {
// Параметром передается базовая директория, в которой будут храниться шаблоны
return new \Slim\Views\PhpRenderer(__DIR__ . '/../view');
});

$app = AppFactory::create();

$app->get('/', function (Request $request, Response $response) {
$response->getBody()->write("Welcome to my third project!");
return $response;
return $this->get('renderer')->renderer('response', 'index.phtml');
});

$app->run();
31 changes: 31 additions & 0 deletions view/index.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Анализатор страниц</title>
</head>
<body class="min-vh-100 d-flex flex-column">
<main class="flex-grow-1">
<div class="container-lg mt-3">
<div class="row">
<div class="col-12 col-md-10 col-lg-8 mx-auto border rounded-3 bg-light p-5">
<h1 class="display-3">Анализатор страниц</h1>
<p class="lead">Бесплатно проверяйте сайты на SEO пригодность</p>
<form action="/urls" method="post" class="row" required="">
<div class="col-8">
<input type="text" name="url[name]" value="" class="form-control form-control-lg" placeholder="https://www.example.com">
</div>
<div class="col-2">
<input type="submit" class="btn btn-primary btn-lg ms-3 px-5 text-uppercase mx-3" value="Проверить">
</div>

</form>

</div>
</div>
</div>
</main>
</body>
</html>

0 comments on commit 730bcd5

Please sign in to comment.