Skip to content

Commit 2945445

Browse files
committed
Switch to plain array symfony config
1 parent 55a9474 commit 2945445

File tree

16 files changed

+261
-237
lines changed

16 files changed

+261
-237
lines changed

config/packages/debug.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
6+
7+
return App::config([
8+
'when@dev' => [
9+
'debug' => [
10+
'dump_destination' => 'tcp://%env(VAR_DUMPER_SERVER)%',
11+
],
12+
],
13+
]);

config/packages/dev/debug.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

config/packages/dev/framework.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

config/packages/dev/web_profiler.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

config/packages/doctrine.php

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,51 @@
22

33
declare(strict_types=1);
44

5-
use Symfony\Config\DoctrineConfig;
5+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
66

7-
return static function (DoctrineConfig $doctrine): void {
8-
$doctrineOrm = $doctrine->orm();
9-
$defaultEm = $doctrineOrm->entityManager('default');
10-
$defaultConnection = $doctrine->dbal()->connection('default');
11-
12-
$defaultConnection
13-
->url('%env(resolve:DATABASE_URL)%')
14-
->profilingCollectBacktrace('%kernel.debug%');
15-
16-
$doctrineOrm
17-
->autoGenerateProxyClasses(true)
18-
->enableLazyGhostObjects(true)
19-
->controllerResolver()
20-
->autoMapping(false);
21-
22-
$defaultEm
23-
->autoMapping(true)
24-
->namingStrategy('doctrine.orm.naming_strategy.underscore_number_aware')
25-
->reportFieldsWhereDeclared(true)
26-
->validateXmlMapping(true)
27-
->mapping('App', [
28-
'alias' => 'App',
29-
'dir' => '%kernel.project_dir%/src/Entity',
30-
'is_bundle' => false,
31-
'prefix' => 'App\Entity',
32-
'type' => 'attribute',
33-
]);
34-
};
7+
return App::config([
8+
'doctrine' => [
9+
'dbal' => [
10+
'connections' => [
11+
'default' => [
12+
'url' => '%env(resolve:DATABASE_URL)%',
13+
'profiling_collect_backtrace' => '%kernel.debug%',
14+
],
15+
],
16+
],
17+
'orm' => [
18+
'auto_generate_proxy_classes' => true,
19+
'enable_lazy_ghost_objects' => true,
20+
'controller_resolver' => [
21+
'auto_mapping' => false,
22+
],
23+
'entity_managers' => [
24+
'default' => [
25+
'auto_mapping' => true,
26+
'naming_strategy' => 'doctrine.orm.naming_strategy.underscore_number_aware',
27+
'validate_xml_mapping' => true,
28+
'mappings' => [
29+
'App' => [
30+
'alias' => 'App',
31+
'dir' => '%kernel.project_dir%/src/Entity',
32+
'is_bundle' => false,
33+
'prefix' => 'App\Entity',
34+
'type' => 'attribute',
35+
],
36+
],
37+
],
38+
],
39+
],
40+
],
41+
'when@test' => [
42+
'doctrine' => [
43+
'dbal' => [
44+
'connections' => [
45+
'default' => [
46+
'dbname_suffix' => '_test%env(default::TEST_TOKEN)%',
47+
],
48+
],
49+
],
50+
],
51+
],
52+
]);

config/packages/framework.php

Lines changed: 72 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,76 @@
22

33
declare(strict_types=1);
44

5-
use Symfony\Config\FrameworkConfig;
5+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
66

7-
return static function (FrameworkConfig $framework): void {
8-
// Cache
9-
$framework->cache();
10-
11-
// Csrf
12-
$framework->form()
13-
->csrfProtection()
14-
->tokenId('submit');
15-
16-
$framework->csrfProtection()
17-
->statelessTokenIds(['submit', 'authenticate', 'logout']);
18-
19-
// Framework
20-
$framework->secret('%env(APP_SECRET)%');
21-
$framework->handleAllThrowables(true);
22-
$framework->session()
23-
->handlerId(null)
24-
->cookieSecure('auto')
25-
->cookieSamesite('lax');
26-
$framework->phpErrors()
27-
->log(true);
28-
29-
// Mailer
30-
$framework->mailer()
31-
->dsn('%env(MAILER_DSN)%');
32-
33-
// Notifier
34-
$framework->notifier()
35-
->chatterTransport('slack', '%env(NOTIFIER_DSN)%');
36-
37-
// PropertyInfo
38-
$framework->propertyInfo()
39-
->withConstructorExtractor(true);
40-
41-
// Routing
42-
$framework->router()
43-
->utf8(true);
44-
45-
// Translation
46-
$framework->defaultLocale('en');
47-
$framework->translator()
48-
->enabled(true)
49-
->defaultPath('%kernel.project_dir%/resources/lang')
50-
->fallbacks('es');
51-
52-
// Validator
53-
$framework->validation([
54-
'email_validation_mode' => 'html5',
55-
]);
56-
};
7+
return App::config([
8+
'framework' => [
9+
'cache' => [],
10+
'csrf_protection' => [
11+
'stateless_token_ids' => ['submit', 'authenticate', 'logout'],
12+
],
13+
'default_locale' => 'en',
14+
'form' => [
15+
'csrf_protection' => [
16+
'token_id' => 'submit',
17+
],
18+
],
19+
'handle_all_throwables' => true,
20+
'mailer' => [
21+
'dsn' => '%env(MAILER_DSN)%',
22+
],
23+
'notifier' => [
24+
'chatter_transports' => [
25+
'slack' => '%env(NOTIFIER_DSN)%',
26+
],
27+
],
28+
'php_errors' => [
29+
'log' => true,
30+
],
31+
'property_info' => [
32+
'with_constructor_extractor' => true,
33+
],
34+
'router' => [
35+
'utf8' => true,
36+
],
37+
'secret' => '%env(APP_SECRET)%',
38+
'session' => [
39+
'handler_id' => null,
40+
'cookie_secure' => 'auto',
41+
'cookie_samesite' => 'lax',
42+
],
43+
'translator' => [
44+
'enabled' => true,
45+
'default_path' => '%kernel.project_dir%/resources/lang',
46+
'fallbacks' => ['es'],
47+
],
48+
'validation' => [
49+
'email_validation_mode' => 'html5',
50+
],
51+
],
52+
'when@dev' => [
53+
'framework' => [
54+
'profiler' => [
55+
'only_exceptions' => false,
56+
'collect_serializer_data' => true,
57+
],
58+
],
59+
],
60+
'when@test' => [
61+
'framework' => [
62+
'profiler' => [
63+
'collect' => false,
64+
'collect_serializer_data' => true,
65+
],
66+
'session' => [
67+
'storage_factory_id' => 'session.storage.factory.mock_file',
68+
],
69+
'test' => true,
70+
'validation' => [
71+
'not_compromised_password' => [
72+
'enabled' => true,
73+
],
74+
],
75+
],
76+
],
77+
]);

config/packages/prod/doctrine.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@
22

33
declare(strict_types=1);
44

5-
use Symfony\Config\DoctrineConfig;
5+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
66

7-
return static function (DoctrineConfig $doctrine): void {
8-
$doctrineOrm = $doctrine->orm();
9-
$defaultEm = $doctrineOrm->entityManager('default');
10-
11-
$doctrineOrm
12-
->autoGenerateProxyClasses(false)
13-
->proxyDir('%kernel.build_dir%/doctrine/orm/Proxies');
14-
$defaultEm->resultCacheDriver()
15-
->type('pool')
16-
->pool('doctrine.result_cache_pool');
17-
$defaultEm->resultCacheDriver()
18-
->type('pool')
19-
->pool('doctrine.system_cache_pool');
20-
};
7+
return App::config([
8+
'doctrine' => [
9+
'orm' => [
10+
'auto_generate_proxy_classes' => false,
11+
'proxy_dir' => '%kernel.build_dir%/doctrine/orm/Proxies',
12+
'entity_managers' => [
13+
'default' => [
14+
'query_cache_driver' => [
15+
'type' => 'pool',
16+
'pool' => 'doctrine.system_cache_pool',
17+
],
18+
'result_cache_driver' => [
19+
'type' => 'pool',
20+
'pool' => 'doctrine.system_cache_pool',
21+
],
22+
],
23+
],
24+
],
25+
],
26+
]);

config/packages/prod/framework.php

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@
22

33
declare(strict_types=1);
44

5-
use Symfony\Config\FrameworkConfig;
5+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
66

7-
return static function (FrameworkConfig $framework): void {
8-
// Doctrine
9-
$framework->cache()
10-
->pool('doctrine.result_cache_pool')->adapters(['cache.app'])
11-
->pool('doctrine.system_cache_pool')->adapters(['cache.system']);
12-
13-
// Routing
14-
$framework->router()
15-
->strictRequirements(null);
16-
};
7+
return App::config([
8+
'framework' => [
9+
// Doctrine
10+
'cache' => [
11+
'pools' => [
12+
'doctrine.result_cache_pool' => [
13+
'adapters' => ['cache.app'],
14+
],
15+
'doctrine.system_cache_pool' => [
16+
'adapters' => ['cache.system'],
17+
],
18+
],
19+
],
20+
'router' => [
21+
'strict_requirements' => null,
22+
],
23+
],
24+
]);

0 commit comments

Comments
 (0)