Source

Target

Commits (6)
Showing with 284 additions and 160 deletions
+284 -160
......@@ -3,7 +3,7 @@
1. Склонировать этот репозиторий `git clone https://git.miem.hse.ru/kaa-framework/demo-application/forum`
2. Поднять контейнеры `docker compose up -d`.
Контейнер с kphp будет падать до того, как вы первый раз успешно проведёте компиляцию.
3. Установить зависимости: `docker compose exec php composer install`
3. Установить зависимости: `docker compose exec -w /app php composer install`
## Генерация и компиляция
* `docker compose exec -w /app php php generate.php` - Запускает кодген
......
......@@ -18,7 +18,7 @@
],
"require": {
"kaa/kaa": "0.0.4"
"kaa/kaa": "0.0.6"
},
"require-dev": {
"symplify/easy-coding-standard": "^12.0",
......
This diff is collapsed.
......@@ -4,6 +4,7 @@ use Kaa\Bundle\Database\DatabaseBundle;
use Kaa\Bundle\DependencyInjection\DependencyInjectionBundle;
use Kaa\Bundle\EventDispatcher\EventDispatcherBundle;
use Kaa\Bundle\HttpKernel\HttpKernelBundle;
use Kaa\Bundle\KTemplate\KTemplateBundle;
use Kaa\Bundle\Router\RouterBundle;
use Kaa\Bundle\Security\SecurityBundle;
use Kaa\Bundle\Validator\ValidatorBundle;
......@@ -17,5 +18,6 @@ return [
RouterBundle::class,
ValidatorBundle::class,
SecurityBundle::class,
KTemplateBundle::class,
'instanceGenerator' => InstanceProvider::class,
];
ktemplate:
path: /app/public/static
url: "http://localhost:8800"
template_path: /app/templates
\ No newline at end of file
......@@ -8,7 +8,7 @@ services:
- .:/app
ports:
- "8800:8800"
- "8801:8800"
working_dir: /app/public
entrypoint: php -S 0.0.0.0:8800
......@@ -21,10 +21,10 @@ services:
- .:/app
ports:
- "8801:8801"
- "8800:8800"
working_dir: /app
entrypoint: kphp_out/server -H 8801 -f 1 --user root
command: kphp_out/server -H 8800 -f 10 --user root
database:
......
/* style.css */
p {
color: white;
background-color: black;
}
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
color: #333;
margin: 0;
padding: 0;
}
header {
background-color: #007bff;
color: red;
padding: 10px;
text-align: center;
}
h1 {
margin-bottom: 20px;
}
.container {
width: 80%;
margin: 0 auto;
}
section {
margin: 20px 0;
}
footer {
background-color: #333;
color: yellow;
padding: 10px;
text-align: center;
position: fixed;
bottom: 0;
width: 100%;
}
\ No newline at end of file
let num1 = 5;
let num2 = 10;
let sum = num1 + num2;
document.getElementById("consoleOutput").innerHTML += "Sum " + num1 + " and " + num2 + " equals " + sum + "<br>";
public/static/pepe.png

37.5 KB

......@@ -3,16 +3,30 @@
namespace App\Controller;
use Kaa\Component\HttpMessage\Response\JsonResponse;
use Kaa\Component\HttpMessage\Response\Response;
use Kaa\Component\RequestMapperDecorator\MapQueryParameter;
use Kaa\Component\RequestMapperDecorator\MapRouteParameter;
use Kaa\Component\Router\Attribute\Get;
use KTemplate\ArrayDataProvider;
use KTemplate\Engine;
class ExampleController
{
private Engine $ktemplate;
public function __construct(
Engine $ktemplate
) {
$this->ktemplate = $ktemplate;
}
#[Get('/test')]
public function test(): JsonResponse
{
return new JsonResponse('{"hame": "kolaya"}', 200);
} # warning for incorrect json for parsing?
public function test(
#[MapQueryParameter]
string $name
): Response {
return new Response($this->ktemplate->render('greeting', new ArrayDataProvider(['name' => $name])));
}
#[Get('/test/{id}')]
public function getTag(
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Download file base64</title>
</head>
<header>
Test
</header>
<body>
<img src="{{ asset("pepe.png", "png") }}">
<p id="consoleOutput"></p>
<script src="{{ asset("js/script.js", "js") }}"></script>
<link rel="stylesheet" type="text/css" href="{{ asset("css/style.css", "css") }}" />
<p>This text will be red as defined in the external stylesheet.</p>
<p>Hello, {{ name }}</p>
<img src="{{ asset("pepe.png", "png") }}">
<p style="color: blue">The <code>style</code> attribute can override it, though.</p>
</body>
<footer>
Test
</footer>
</html>
\ No newline at end of file