Skip to content

Commit c56d662

Browse files
committed
Only require Twig when profiler is enabled
1 parent f94de3b commit c56d662

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

DependencyInjection/Configuration.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Http\Message\CookieJar;
88
use Http\Message\Formatter;
99
use Http\Message\StreamFactory;
10+
use InvalidArgumentException;
1011
use Psr\Cache\CacheItemPoolInterface;
1112
use Psr\Log\LoggerInterface;
1213
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
@@ -137,6 +138,16 @@ public function getConfigTreeBuilder()
137138
->booleanNode('enabled')
138139
->info('Turn the toolbar on or off. Defaults to kernel debug mode.')
139140
->defaultValue($this->debug)
141+
->validate()
142+
->ifTrue()
143+
->then(function ($v) {
144+
if (!class_exists(\Twig_Environment::class)) {
145+
throw new InvalidArgumentException('Twig needs to be installed when enabling the profiler.');
146+
}
147+
148+
return $v;
149+
})
150+
->end()
140151
->end()
141152
->scalarNode('formatter')->defaultNull()->end()
142153
->integerNode('captured_body_length')

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
"symfony/dependency-injection": "^2.8.49 || ^3.0.9 || ^3.1.10 || ^3.2.14 || ^3.3.18 || ^3.4.20 || ^4.0.15 || ^4.1.9 || ^4.2.1",
3232
"symfony/event-dispatcher": "^2.8.49 || ^3.0.9 || ^3.1.10 || ^3.2.14 || ^3.3.18 || ^3.4.20 || ^4.0.15 || ^4.1.9 || ^4.2.1",
3333
"symfony/http-kernel": "^2.8.49 || ^3.0.9 || ^3.1.10 || ^3.2.14 || ^3.3.18 || ^3.4.20 || ^4.0.15 || ^4.1.9 || ^4.2.1",
34-
"symfony/options-resolver": "^2.8.49 || ^3.0.9 || ^3.1.10 || ^3.2.14 || ^3.3.18 || ^3.4.20 || ^4.0.15 || ^4.1.9 || ^4.2.1",
35-
"twig/twig": "^1.36 || ^2.6"
34+
"symfony/options-resolver": "^2.8.49 || ^3.0.9 || ^3.1.10 || ^3.2.14 || ^3.3.18 || ^3.4.20 || ^4.0.15 || ^4.1.9 || ^4.2.1"
3635
},
3736
"require-dev": {
3837
"guzzlehttp/psr7": "^1.0",
@@ -50,13 +49,15 @@
5049
"symfony/phpunit-bridge": "^3.4 || ^4.2",
5150
"symfony/stopwatch": "^2.8.49 || ^3.0.9 || ^3.1.10 || ^3.2.14 || ^3.3.18 || ^3.4.20 || ^4.0.15 || ^4.1.9 || ^4.2.1",
5251
"symfony/twig-bundle": "^2.8.49 || ^3.0.9 || ^3.1.10 || ^3.2.14 || ^3.3.18 || ^3.4.20 || ^4.0.15 || ^4.1.9 || ^4.2.1",
53-
"symfony/web-profiler-bundle": "^2.8.49 || ^3.0.9 || ^3.1.10 || ^3.2.14 || ^3.3.18 || ^3.4.20 || ^4.0.15 || ^4.1.9 || ^4.2.1"
52+
"symfony/web-profiler-bundle": "^2.8.49 || ^3.0.9 || ^3.1.10 || ^3.2.14 || ^3.3.18 || ^3.4.20 || ^4.0.15 || ^4.1.9 || ^4.2.1",
53+
"twig/twig": "^1.36 || ^2.6"
5454
},
5555
"conflict": {
5656
"php-http/guzzle6-adapter": "<1.1"
5757
},
5858
"suggest": {
59-
"php-http/mock-client": "Add this to your require-dev section to mock HTTP responses easily"
59+
"php-http/mock-client": "Add this to your require-dev section to mock HTTP responses easily",
60+
"twig/twig": "Add this to your require-dev section if you want to use the Symfony Profiler"
6061
},
6162
"autoload": {
6263
"psr-4": {

0 commit comments

Comments
 (0)