add Settings class and Twig cache settings
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
92a4d2fcf8
commit
808681e87a
|
|
@ -0,0 +1,4 @@
|
||||||
|
# .env.development: Environment variables for local development
|
||||||
|
|
||||||
|
# Disable Twig cache
|
||||||
|
TWIG_CACHE_DIR=
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
# .env.testing: Environment variables for testing deployment
|
||||||
|
|
||||||
|
# Disable Twig cache -- TODO enable cache
|
||||||
|
TWIG_CACHE_DIR=
|
||||||
|
|
@ -8,5 +8,7 @@ services:
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- 8080:80
|
- 8080:80
|
||||||
|
env_file:
|
||||||
|
- .env.development
|
||||||
volumes:
|
volumes:
|
||||||
- ../:/var/www/
|
- ../:/var/www/
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ services:
|
||||||
context: ..
|
context: ..
|
||||||
target: production
|
target: production
|
||||||
restart: always
|
restart: always
|
||||||
|
env_file:
|
||||||
|
- .env.testing
|
||||||
networks:
|
networks:
|
||||||
- traefik
|
- traefik
|
||||||
labels:
|
labels:
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,19 @@ class Dependencies
|
||||||
{
|
{
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
|
|
||||||
|
// App settings
|
||||||
|
$container->set(Settings::class, function (): Settings {
|
||||||
|
return new Settings();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Twig template engine
|
||||||
|
$container->set(self::TWIG, function (ContainerInterface $c) {
|
||||||
|
/** @var Settings $settings */
|
||||||
|
$settings = $c->get(Settings::class);
|
||||||
|
|
||||||
|
return Twig::create(self::TWIG_TEMPLATE_DIR, $settings->getTwigSettings());
|
||||||
|
});
|
||||||
|
|
||||||
// Controllers
|
// Controllers
|
||||||
$container->set(HelloWorldController::class, function (ContainerInterface $c) {
|
$container->set(HelloWorldController::class, function (ContainerInterface $c) {
|
||||||
return new HelloWorldController(
|
return new HelloWorldController(
|
||||||
|
|
@ -29,12 +42,6 @@ class Dependencies
|
||||||
return new HelloWorld();
|
return new HelloWorld();
|
||||||
});
|
});
|
||||||
|
|
||||||
$container->set(self::TWIG, function (ContainerInterface $c) {
|
|
||||||
// TODO cache
|
|
||||||
$twigSettings = [];
|
|
||||||
return Twig::create(self::TWIG_TEMPLATE_DIR, $twigSettings);
|
|
||||||
});
|
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace NoteCat;
|
||||||
|
|
||||||
|
class Settings
|
||||||
|
{
|
||||||
|
public function getTwigSettings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'cache' => getenv('TWIG_CACHE_DIR') ?? false,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue