Skip to content

Commit e4b08f6

Browse files
committed
feat: added twig
1 parent b12ae87 commit e4b08f6

File tree

9 files changed

+62
-1
lines changed

9 files changed

+62
-1
lines changed

.docker/php/start.sh

+2
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ if [ $ENABLE_XDEBUG == "1" ]; then
99
docker-php-ext-enable xdebug
1010
fi
1111

12+
php ./bin/console doctrine:migrations:migrate --no-interaction
13+
1214
docker-php-entrypoint php-fpm

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"symfony/flex": "^1.3.1",
1010
"symfony/framework-bundle": "5.0.*",
1111
"symfony/orm-pack": "^1.0",
12+
"symfony/twig-pack": "^1.0",
1213
"symfony/yaml": "5.0.*",
1314
"vlucas/phpdotenv": "~4.1"
1415
},

config/bundles.php

+2
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
77
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
88
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
9+
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
10+
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
911
];

config/packages/test/twig.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
twig:
2+
strict_variables: true

config/packages/twig.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
twig:
2+
default_path: '%kernel.project_dir%/templates'

src/Controller/IndexController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ class IndexController extends AbstractController
1313
*/
1414
public function main(): Response
1515
{
16-
return new Response('Hello world!');
16+
return $this->render('main.html.twig', ['message' => 'hello world!']);
1717
}
1818
}

symfony.lock

+35
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@
213213
"phpdocumentor/type-resolver": {
214214
"version": "1.1.0"
215215
},
216+
"phpoption/phpoption": {
217+
"version": "1.7.3"
218+
},
216219
"phpro/grumphp": {
217220
"version": "v0.17.2"
218221
},
@@ -487,6 +490,29 @@
487490
"symfony/stopwatch": {
488491
"version": "v5.0.7"
489492
},
493+
"symfony/translation-contracts": {
494+
"version": "v2.0.1"
495+
},
496+
"symfony/twig-bridge": {
497+
"version": "v5.0.7"
498+
},
499+
"symfony/twig-bundle": {
500+
"version": "5.0",
501+
"recipe": {
502+
"repo": "github.com/symfony/recipes",
503+
"branch": "master",
504+
"version": "5.0",
505+
"ref": "fab9149bbaa4d5eca054ed93f9e1b66cc500895d"
506+
},
507+
"files": [
508+
"config/packages/test/twig.yaml",
509+
"config/packages/twig.yaml",
510+
"templates/base.html.twig"
511+
]
512+
},
513+
"symfony/twig-pack": {
514+
"version": "v1.0.0"
515+
},
490516
"symfony/var-dumper": {
491517
"version": "v5.0.7"
492518
},
@@ -499,9 +525,18 @@
499525
"theseer/tokenizer": {
500526
"version": "1.1.3"
501527
},
528+
"twig/extra-bundle": {
529+
"version": "v3.0.3"
530+
},
531+
"twig/twig": {
532+
"version": "v3.0.3"
533+
},
502534
"vimeo/psalm": {
503535
"version": "3.10.1"
504536
},
537+
"vlucas/phpdotenv": {
538+
"version": "v4.1.3"
539+
},
505540
"wearejust/grumphp-extra-tasks": {
506541
"version": "2.2.1"
507542
},

templates/base.html.twig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>{% block title %}Welcome!{% endblock %}</title>
6+
{% block stylesheets %}{% endblock %}
7+
</head>
8+
<body>
9+
{% block body %}{% endblock %}
10+
{% block javascripts %}{% endblock %}
11+
</body>
12+
</html>

templates/main.html.twig

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% extends "base.html.twig" %}
2+
3+
{% block body %}
4+
<h1>{{message}}
5+
{% endblock %}

0 commit comments

Comments
 (0)