Skip to content
This repository was archived by the owner on Oct 22, 2021. It is now read-only.

Commit 846eb0b

Browse files
committed
Add slim 4 setup description
1 parent 88cad4c commit 846eb0b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,19 +232,20 @@ This script is only an example and must be adapted to your individual environmen
232232
File: `bin/parse-twig.php`
233233

234234
```php
235-
<?php
235+
use Odan\Twig\TwigCompiler;
236+
use Slim\App;
237+
use Twig\Environment as Twig;
236238

237-
require_once __DIR__ . '/../vendor/autoload.php';
239+
/** @var App $app */
240+
$app = require __DIR__ . '/../config/bootstrap.php';
238241

239-
// Specify our Twig templates location
240-
$loader = new \Twig\Loader\FilesystemLoader(__DIR__ . '/../templates');
242+
$settings = $app->getContainer()->get('settings')['twig'];
243+
$templatePath = (string)$settings['path'];
244+
$cachePath = (string)$settings['cache_path'];
241245

242-
// Instantiate Twig
243-
$twig = new \Twig\Environment($loader);
246+
$twig = $app->getContainer()->get(Twig::class);
244247

245-
// Compile all Twig templates into the cache directory
246-
$cachePath = __DIR__ . '/../tmp/twig-cache';
247-
$compiler = new \Odan\Twig\TwigCompiler($twig, $cachePath);
248+
$compiler = new TwigCompiler($twig, $cachePath);
248249
$compiler->compile();
249250

250251
echo "Done\n";

0 commit comments

Comments
 (0)