From 28f184dd68f946c213f79f2bf129190b68cc5e0e Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Thu, 3 Nov 2022 10:44:05 -0400 Subject: [PATCH] Convert config to php --- config/packages/cache.php | 9 +++++ config/packages/cache.yaml | 19 ---------- config/packages/dev/easy_log_handler.php | 13 +++++++ config/packages/dev/easy_log_handler.yaml | 16 --------- config/packages/dev/monolog.php | 9 +++++ config/packages/dev/monolog.yaml | 19 ---------- config/packages/dev/routing.php | 9 +++++ config/packages/dev/routing.yaml | 3 -- config/packages/dev/web_profiler.php | 11 ++++++ config/packages/dev/web_profiler.yaml | 6 ---- config/packages/doctrine.php | 34 ++++++++++++++++++ config/packages/doctrine.yaml | 30 ---------------- config/packages/doctrine_migrations.php | 8 +++++ config/packages/doctrine_migrations.yaml | 4 --- config/packages/framework.php | 15 ++++++++ config/packages/framework.yaml | 17 --------- config/packages/prod/deprecations.php | 0 config/packages/prod/deprecations.yaml | 8 ----- config/packages/prod/doctrine.php | 22 ++++++++++++ config/packages/prod/doctrine.yaml | 31 ---------------- config/packages/prod/monolog.php | 9 +++++ config/packages/prod/monolog.yaml | 17 --------- config/packages/prod/routing.php | 9 +++++ config/packages/prod/routing.yaml | 3 -- config/packages/routing.php | 9 +++++ config/packages/routing.yaml | 4 --- config/packages/security.php | 13 +++++++ config/packages/security.yaml | 39 --------------------- config/packages/sensio_framework_extra.php | 9 +++++ config/packages/sensio_framework_extra.yaml | 3 -- config/packages/test/framework.php | 9 +++++ config/packages/test/framework.yaml | 4 --- config/packages/test/monolog.php | 9 +++++ config/packages/test/monolog.yaml | 7 ---- config/packages/test/twig.php | 9 +++++ config/packages/test/twig.yaml | 2 -- config/packages/test/validator.php | 9 +++++ config/packages/test/validator.yaml | 3 -- config/packages/test/web_profiler.php | 11 ++++++ config/packages/test/web_profiler.yaml | 6 ---- config/packages/translation.php | 9 +++++ config/packages/translation.yaml | 6 ---- config/packages/twig.php | 9 +++++ config/packages/twig.yaml | 6 ---- config/packages/validator.php | 9 +++++ config/packages/validator.yaml | 8 ----- config/routes.php | 11 ++++++ config/routes.yaml | 3 -- config/routes/annotations.php | 7 ++++ config/routes/annotations.yaml | 3 -- config/routes/dev/framework.php | 8 +++++ config/routes/dev/framework.yaml | 3 -- config/routes/dev/twig.yaml | 3 -- config/routes/dev/web_profiler.php | 11 ++++++ config/routes/dev/web_profiler.yaml | 7 ---- config/services.php | 37 +++++++++++++++++++ config/services.yaml | 39 --------------------- src/Kernel.php | 24 +++++++++---- 58 files changed, 345 insertions(+), 325 deletions(-) create mode 100644 config/packages/cache.php delete mode 100644 config/packages/cache.yaml create mode 100644 config/packages/dev/easy_log_handler.php delete mode 100644 config/packages/dev/easy_log_handler.yaml create mode 100644 config/packages/dev/monolog.php delete mode 100644 config/packages/dev/monolog.yaml create mode 100644 config/packages/dev/routing.php delete mode 100644 config/packages/dev/routing.yaml create mode 100644 config/packages/dev/web_profiler.php delete mode 100644 config/packages/dev/web_profiler.yaml create mode 100644 config/packages/doctrine.php delete mode 100644 config/packages/doctrine.yaml create mode 100644 config/packages/doctrine_migrations.php delete mode 100644 config/packages/doctrine_migrations.yaml create mode 100644 config/packages/framework.php delete mode 100644 config/packages/framework.yaml create mode 100644 config/packages/prod/deprecations.php delete mode 100644 config/packages/prod/deprecations.yaml create mode 100644 config/packages/prod/doctrine.php delete mode 100644 config/packages/prod/doctrine.yaml create mode 100644 config/packages/prod/monolog.php delete mode 100644 config/packages/prod/monolog.yaml create mode 100644 config/packages/prod/routing.php delete mode 100644 config/packages/prod/routing.yaml create mode 100644 config/packages/routing.php delete mode 100644 config/packages/routing.yaml create mode 100644 config/packages/security.php delete mode 100644 config/packages/security.yaml create mode 100644 config/packages/sensio_framework_extra.php delete mode 100644 config/packages/sensio_framework_extra.yaml create mode 100644 config/packages/test/framework.php delete mode 100644 config/packages/test/framework.yaml create mode 100644 config/packages/test/monolog.php delete mode 100644 config/packages/test/monolog.yaml create mode 100644 config/packages/test/twig.php delete mode 100644 config/packages/test/twig.yaml create mode 100644 config/packages/test/validator.php delete mode 100644 config/packages/test/validator.yaml create mode 100644 config/packages/test/web_profiler.php delete mode 100644 config/packages/test/web_profiler.yaml create mode 100644 config/packages/translation.php delete mode 100644 config/packages/translation.yaml create mode 100644 config/packages/twig.php delete mode 100644 config/packages/twig.yaml create mode 100644 config/packages/validator.php delete mode 100644 config/packages/validator.yaml create mode 100644 config/routes.php delete mode 100644 config/routes.yaml create mode 100644 config/routes/annotations.php delete mode 100644 config/routes/annotations.yaml create mode 100644 config/routes/dev/framework.php delete mode 100644 config/routes/dev/framework.yaml delete mode 100644 config/routes/dev/twig.yaml create mode 100644 config/routes/dev/web_profiler.php delete mode 100644 config/routes/dev/web_profiler.yaml create mode 100644 config/services.php delete mode 100644 config/services.yaml diff --git a/config/packages/cache.php b/config/packages/cache.php new file mode 100644 index 0000000..b7b5cc4 --- /dev/null +++ b/config/packages/cache.php @@ -0,0 +1,9 @@ +extension('framework', ['cache' => null]); +}; diff --git a/config/packages/cache.yaml b/config/packages/cache.yaml deleted file mode 100644 index 6899b72..0000000 --- a/config/packages/cache.yaml +++ /dev/null @@ -1,19 +0,0 @@ -framework: - cache: - # Unique name of your app: used to compute stable namespaces for cache keys. - #prefix_seed: your_vendor_name/app_name - - # The "app" cache stores to the filesystem by default. - # The data in this cache should persist between deploys. - # Other options include: - - # Redis - #app: cache.adapter.redis - #default_redis_provider: redis://localhost - - # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues) - #app: cache.adapter.apcu - - # Namespaced pools use the above "app" backend by default - #pools: - #my.dedicated.cache: null diff --git a/config/packages/dev/easy_log_handler.php b/config/packages/dev/easy_log_handler.php new file mode 100644 index 0000000..3080b12 --- /dev/null +++ b/config/packages/dev/easy_log_handler.php @@ -0,0 +1,13 @@ +services(); + + $services->set('EasyCorp\EasyLog\EasyLogHandler') + ->private() + ->args(['%kernel.logs_dir%/%kernel.environment%.log']); +}; diff --git a/config/packages/dev/easy_log_handler.yaml b/config/packages/dev/easy_log_handler.yaml deleted file mode 100644 index 27bfc60..0000000 --- a/config/packages/dev/easy_log_handler.yaml +++ /dev/null @@ -1,16 +0,0 @@ -services: - EasyCorp\EasyLog\EasyLogHandler: - public: false - arguments: ['%kernel.logs_dir%/%kernel.environment%.log'] - -#// FIXME: How to add this configuration automatically without messing up with the monolog configuration? -#monolog: -# handlers: -# buffered: -# type: buffer -# handler: easylog -# channels: ['!event'] -# level: debug -# easylog: -# type: service -# id: EasyCorp\EasyLog\EasyLogHandler diff --git a/config/packages/dev/monolog.php b/config/packages/dev/monolog.php new file mode 100644 index 0000000..a7988c4 --- /dev/null +++ b/config/packages/dev/monolog.php @@ -0,0 +1,9 @@ +extension('monolog', ['handlers' => ['main' => ['type' => 'stream', 'path' => '%kernel.logs_dir%/%kernel.environment%.log', 'level' => 'debug', 'channels' => ['!event']], 'console' => ['type' => 'console', 'process_psr_3_messages' => false, 'channels' => ['!event', '!doctrine', '!console']]]]); +}; diff --git a/config/packages/dev/monolog.yaml b/config/packages/dev/monolog.yaml deleted file mode 100644 index b1998da..0000000 --- a/config/packages/dev/monolog.yaml +++ /dev/null @@ -1,19 +0,0 @@ -monolog: - handlers: - main: - type: stream - path: "%kernel.logs_dir%/%kernel.environment%.log" - level: debug - channels: ["!event"] - # uncomment to get logging in your browser - # you may have to allow bigger header sizes in your Web server configuration - #firephp: - # type: firephp - # level: info - #chromephp: - # type: chromephp - # level: info - console: - type: console - process_psr_3_messages: false - channels: ["!event", "!doctrine", "!console"] diff --git a/config/packages/dev/routing.php b/config/packages/dev/routing.php new file mode 100644 index 0000000..71e9b1f --- /dev/null +++ b/config/packages/dev/routing.php @@ -0,0 +1,9 @@ +extension('framework', ['router' => ['strict_requirements' => true]]); +}; diff --git a/config/packages/dev/routing.yaml b/config/packages/dev/routing.yaml deleted file mode 100644 index 4116679..0000000 --- a/config/packages/dev/routing.yaml +++ /dev/null @@ -1,3 +0,0 @@ -framework: - router: - strict_requirements: true diff --git a/config/packages/dev/web_profiler.php b/config/packages/dev/web_profiler.php new file mode 100644 index 0000000..739dbcb --- /dev/null +++ b/config/packages/dev/web_profiler.php @@ -0,0 +1,11 @@ +extension('web_profiler', ['toolbar' => true, 'intercept_redirects' => false]); + + $containerConfigurator->extension('framework', ['profiler' => ['only_exceptions' => false]]); +}; diff --git a/config/packages/dev/web_profiler.yaml b/config/packages/dev/web_profiler.yaml deleted file mode 100644 index e92166a..0000000 --- a/config/packages/dev/web_profiler.yaml +++ /dev/null @@ -1,6 +0,0 @@ -web_profiler: - toolbar: true - intercept_redirects: false - -framework: - profiler: { only_exceptions: false } diff --git a/config/packages/doctrine.php b/config/packages/doctrine.php new file mode 100644 index 0000000..5e24ffb --- /dev/null +++ b/config/packages/doctrine.php @@ -0,0 +1,34 @@ +parameters(); + + $parameters->set('env(DATABASE_URL)', ''); + + $containerConfigurator->extension('doctrine', [ + 'dbal' => [ + 'driver' => 'pdo_pgsql', + 'types' => ['money' => MoneyType::class], + 'mapping_types' => ['bit' => 'boolean', 'money' => 'money'], + 'url' => '%env(DATABASE_URL)%' + ], + 'orm' => [ + 'auto_generate_proxy_classes' => '%kernel.debug%', + 'naming_strategy' => 'doctrine.orm.naming_strategy.underscore_number_aware', + 'auto_mapping' => TRUE, + 'mappings' => [ + 'App' => [ + 'is_bundle' => FALSE, + 'type' => 'attribute', + 'dir' => '%kernel.project_dir%/src/Entity', + 'prefix' => 'App\Entity', + 'alias' => 'App'] + ] + ] + ]); +}; diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml deleted file mode 100644 index 92127be..0000000 --- a/config/packages/doctrine.yaml +++ /dev/null @@ -1,30 +0,0 @@ -parameters: - # Adds a fallback DATABASE_URL if the env var is not set. - # This allows you to run cache:warmup even if your - # environment variables are not available yet. - # You should not need to change this value. - env(DATABASE_URL): '' - -doctrine: - dbal: - # configure these for your database server - driver: 'pdo_pgsql' - types: - money: App\Types\MoneyType - mapping_types: - bit: boolean - money: money - - # With Symfony 3.3, remove the `resolve:` prefix - url: '%env(DATABASE_URL)%' - orm: - auto_generate_proxy_classes: '%kernel.debug%' - naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware - auto_mapping: true - mappings: - App: - is_bundle: false - type: attribute - dir: '%kernel.project_dir%/src/Entity' - prefix: 'App\Entity' - alias: App diff --git a/config/packages/doctrine_migrations.php b/config/packages/doctrine_migrations.php new file mode 100644 index 0000000..b171802 --- /dev/null +++ b/config/packages/doctrine_migrations.php @@ -0,0 +1,8 @@ +migrationsPath('App\\Migrations', '%kernel.project_dir%/src/Migrations') + ->checkDatabasePlatform(true); +}; diff --git a/config/packages/doctrine_migrations.yaml b/config/packages/doctrine_migrations.yaml deleted file mode 100644 index 9f840a2..0000000 --- a/config/packages/doctrine_migrations.yaml +++ /dev/null @@ -1,4 +0,0 @@ -doctrine_migrations: - migrations_paths: - 'App\Migrations': '%kernel.project_dir%/src/Migrations' - check_database_platform: true diff --git a/config/packages/framework.php b/config/packages/framework.php new file mode 100644 index 0000000..ff2b94a --- /dev/null +++ b/config/packages/framework.php @@ -0,0 +1,15 @@ +extension('framework', [ + 'secret' => '%env(APP_SECRET)%', + 'default_locale' => 'en', + 'http_method_override' => false, + 'session' => ['handler_id' => null], + 'php_errors' => ['log' => true] + ]); +}; diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml deleted file mode 100644 index 9f8bbf5..0000000 --- a/config/packages/framework.yaml +++ /dev/null @@ -1,17 +0,0 @@ -framework: - secret: '%env(APP_SECRET)%' - default_locale: en - #csrf_protection: ~ - http_method_override: false - #trusted_hosts: ~ - - # uncomment this entire section to enable sessions - session: - # With this config, PHP's native session handling is used - handler_id: ~ - #storage_id: session.storage.factory.native - - #esi: ~ - #fragments: ~ - php_errors: - log: true diff --git a/config/packages/prod/deprecations.php b/config/packages/prod/deprecations.php new file mode 100644 index 0000000..e69de29 diff --git a/config/packages/prod/deprecations.yaml b/config/packages/prod/deprecations.yaml deleted file mode 100644 index 920a061..0000000 --- a/config/packages/prod/deprecations.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# As of Symfony 5.1, deprecations are logged in the dedicated "deprecation" channel when it exists -#monolog: -# channels: [deprecation] -# handlers: -# deprecation: -# type: stream -# channels: [deprecation] -# path: "%kernel.logs_dir%/%kernel.environment%.deprecations.log" diff --git a/config/packages/prod/doctrine.php b/config/packages/prod/doctrine.php new file mode 100644 index 0000000..1cb02a4 --- /dev/null +++ b/config/packages/prod/doctrine.php @@ -0,0 +1,22 @@ +extension('doctrine', ['orm' => ['metadata_cache_driver' => ['type' => 'service', 'id' => 'doctrine.system_cache_provider'], 'query_cache_driver' => ['type' => 'service', 'id' => 'doctrine.system_cache_provider'], 'result_cache_driver' => ['type' => 'service', 'id' => 'doctrine.result_cache_provider']]]); + + $services = $containerConfigurator->services(); + + $services->set('doctrine.result_cache_provider', 'Symfony\Component\Cache\DoctrineProvider') + ->private() + ->args([service('doctrine.result_cache_pool')]); + + $services->set('doctrine.system_cache_provider', 'Symfony\Component\Cache\DoctrineProvider') + ->private() + ->args([service('doctrine.system_cache_pool')]); + + $containerConfigurator->extension('framework', ['cache' => ['pools' => ['doctrine.result_cache_pool' => ['adapter' => 'cache.app'], 'doctrine.system_cache_pool' => ['adapter' => 'cache.system']]]]); +}; diff --git a/config/packages/prod/doctrine.yaml b/config/packages/prod/doctrine.yaml deleted file mode 100644 index 2f16f0f..0000000 --- a/config/packages/prod/doctrine.yaml +++ /dev/null @@ -1,31 +0,0 @@ -doctrine: - orm: - metadata_cache_driver: - type: service - id: doctrine.system_cache_provider - query_cache_driver: - type: service - id: doctrine.system_cache_provider - result_cache_driver: - type: service - id: doctrine.result_cache_provider - -services: - doctrine.result_cache_provider: - class: Symfony\Component\Cache\DoctrineProvider - public: false - arguments: - - '@doctrine.result_cache_pool' - doctrine.system_cache_provider: - class: Symfony\Component\Cache\DoctrineProvider - public: false - arguments: - - '@doctrine.system_cache_pool' - -framework: - cache: - pools: - doctrine.result_cache_pool: - adapter: cache.app - doctrine.system_cache_pool: - adapter: cache.system diff --git a/config/packages/prod/monolog.php b/config/packages/prod/monolog.php new file mode 100644 index 0000000..21f7358 --- /dev/null +++ b/config/packages/prod/monolog.php @@ -0,0 +1,9 @@ +extension('monolog', ['handlers' => ['main' => ['type' => 'fingers_crossed', 'action_level' => 'error', 'handler' => 'nested', 'excluded_404s' => ['^/']], 'nested' => ['type' => 'stream', 'path' => '%kernel.logs_dir%/%kernel.environment%.log', 'level' => 'debug'], 'console' => ['type' => 'console', 'process_psr_3_messages' => false, 'channels' => ['!event', '!doctrine']]]]); +}; diff --git a/config/packages/prod/monolog.yaml b/config/packages/prod/monolog.yaml deleted file mode 100644 index 1677234..0000000 --- a/config/packages/prod/monolog.yaml +++ /dev/null @@ -1,17 +0,0 @@ -monolog: - handlers: - main: - type: fingers_crossed - action_level: error - handler: nested - excluded_404s: - # regex: exclude all 404 errors from the logs - - ^/ - nested: - type: stream - path: "%kernel.logs_dir%/%kernel.environment%.log" - level: debug - console: - type: console - process_psr_3_messages: false - channels: ["!event", "!doctrine"] diff --git a/config/packages/prod/routing.php b/config/packages/prod/routing.php new file mode 100644 index 0000000..bd1f940 --- /dev/null +++ b/config/packages/prod/routing.php @@ -0,0 +1,9 @@ +extension('framework', ['router' => ['strict_requirements' => null]]); +}; diff --git a/config/packages/prod/routing.yaml b/config/packages/prod/routing.yaml deleted file mode 100644 index b3e6a0a..0000000 --- a/config/packages/prod/routing.yaml +++ /dev/null @@ -1,3 +0,0 @@ -framework: - router: - strict_requirements: null diff --git a/config/packages/routing.php b/config/packages/routing.php new file mode 100644 index 0000000..193c6c4 --- /dev/null +++ b/config/packages/routing.php @@ -0,0 +1,9 @@ +extension('framework', ['router' => ['strict_requirements' => null, 'utf8' => true]]); +}; diff --git a/config/packages/routing.yaml b/config/packages/routing.yaml deleted file mode 100644 index a15c4ec..0000000 --- a/config/packages/routing.yaml +++ /dev/null @@ -1,4 +0,0 @@ -framework: - router: - strict_requirements: ~ - utf8: true diff --git a/config/packages/security.php b/config/packages/security.php new file mode 100644 index 0000000..b769c7d --- /dev/null +++ b/config/packages/security.php @@ -0,0 +1,13 @@ +extension('security', ['password_hashers' => [PasswordAuthenticatedUserInterface::class => 'auto'], 'providers' => ['users_in_memory' => ['memory' => null]], 'firewalls' => ['dev' => ['pattern' => '^/(_(profiler|wdt)|css|images|js)/', 'security' => false], 'main' => ['lazy' => true, 'provider' => 'users_in_memory']], 'access_control' => null]); + if ($containerConfigurator->env() === 'test') { + $containerConfigurator->extension('security', ['password_hashers' => [PasswordAuthenticatedUserInterface::class => ['algorithm' => 'auto', 'cost' => 4, 'time_cost' => 3, 'memory_cost' => 10]]]); + } +}; diff --git a/config/packages/security.yaml b/config/packages/security.yaml deleted file mode 100644 index 367af25..0000000 --- a/config/packages/security.yaml +++ /dev/null @@ -1,39 +0,0 @@ -security: - # https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords - password_hashers: - Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto' - # https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider - providers: - users_in_memory: { memory: null } - firewalls: - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - main: - lazy: true - provider: users_in_memory - - # activate different ways to authenticate - # https://symfony.com/doc/current/security.html#the-firewall - - # https://symfony.com/doc/current/security/impersonating_user.html - # switch_user: true - - # Easy way to control access for large sections of your site - # Note: Only the *first* access control that matches will be used - access_control: - # - { path: ^/admin, roles: ROLE_ADMIN } - # - { path: ^/profile, roles: ROLE_USER } - -when@test: - security: - password_hashers: - # By default, password hashers are resource intensive and take time. This is - # important to generate secure password hashes. In tests however, secure hashes - # are not important, waste resources and increase test times. The following - # reduces the work factor to the lowest possible values. - Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: - algorithm: auto - cost: 4 # Lowest possible value for bcrypt - time_cost: 3 # Lowest possible value for argon - memory_cost: 10 # Lowest possible value for argon diff --git a/config/packages/sensio_framework_extra.php b/config/packages/sensio_framework_extra.php new file mode 100644 index 0000000..ef67e0f --- /dev/null +++ b/config/packages/sensio_framework_extra.php @@ -0,0 +1,9 @@ +extension('sensio_framework_extra', ['router' => ['annotations' => false]]); +}; diff --git a/config/packages/sensio_framework_extra.yaml b/config/packages/sensio_framework_extra.yaml deleted file mode 100644 index 1821ccc..0000000 --- a/config/packages/sensio_framework_extra.yaml +++ /dev/null @@ -1,3 +0,0 @@ -sensio_framework_extra: - router: - annotations: false diff --git a/config/packages/test/framework.php b/config/packages/test/framework.php new file mode 100644 index 0000000..ade2b9d --- /dev/null +++ b/config/packages/test/framework.php @@ -0,0 +1,9 @@ +extension('framework', ['test' => null]); +}; diff --git a/config/packages/test/framework.yaml b/config/packages/test/framework.yaml deleted file mode 100644 index 9c5dc40..0000000 --- a/config/packages/test/framework.yaml +++ /dev/null @@ -1,4 +0,0 @@ -framework: - test: ~ - #session: - # storage_id: session.storage.mock_file diff --git a/config/packages/test/monolog.php b/config/packages/test/monolog.php new file mode 100644 index 0000000..2d21b6b --- /dev/null +++ b/config/packages/test/monolog.php @@ -0,0 +1,9 @@ +extension('monolog', ['handlers' => ['main' => ['type' => 'stream', 'path' => '%kernel.logs_dir%/%kernel.environment%.log', 'level' => 'debug', 'channels' => ['!event']]]]); +}; diff --git a/config/packages/test/monolog.yaml b/config/packages/test/monolog.yaml deleted file mode 100644 index 2762653..0000000 --- a/config/packages/test/monolog.yaml +++ /dev/null @@ -1,7 +0,0 @@ -monolog: - handlers: - main: - type: stream - path: "%kernel.logs_dir%/%kernel.environment%.log" - level: debug - channels: ["!event"] diff --git a/config/packages/test/twig.php b/config/packages/test/twig.php new file mode 100644 index 0000000..26121df --- /dev/null +++ b/config/packages/test/twig.php @@ -0,0 +1,9 @@ +extension('twig', ['strict_variables' => true]); +}; diff --git a/config/packages/test/twig.yaml b/config/packages/test/twig.yaml deleted file mode 100644 index 8c6e0b4..0000000 --- a/config/packages/test/twig.yaml +++ /dev/null @@ -1,2 +0,0 @@ -twig: - strict_variables: true diff --git a/config/packages/test/validator.php b/config/packages/test/validator.php new file mode 100644 index 0000000..5b71dde --- /dev/null +++ b/config/packages/test/validator.php @@ -0,0 +1,9 @@ +extension('framework', ['validation' => ['not_compromised_password' => false]]); +}; diff --git a/config/packages/test/validator.yaml b/config/packages/test/validator.yaml deleted file mode 100644 index 1e5ab78..0000000 --- a/config/packages/test/validator.yaml +++ /dev/null @@ -1,3 +0,0 @@ -framework: - validation: - not_compromised_password: false diff --git a/config/packages/test/web_profiler.php b/config/packages/test/web_profiler.php new file mode 100644 index 0000000..ed8f9a3 --- /dev/null +++ b/config/packages/test/web_profiler.php @@ -0,0 +1,11 @@ +extension('web_profiler', ['toolbar' => false, 'intercept_redirects' => false]); + + $containerConfigurator->extension('framework', ['profiler' => ['collect' => false]]); +}; diff --git a/config/packages/test/web_profiler.yaml b/config/packages/test/web_profiler.yaml deleted file mode 100644 index 03752de..0000000 --- a/config/packages/test/web_profiler.yaml +++ /dev/null @@ -1,6 +0,0 @@ -web_profiler: - toolbar: false - intercept_redirects: false - -framework: - profiler: { collect: false } diff --git a/config/packages/translation.php b/config/packages/translation.php new file mode 100644 index 0000000..76466bd --- /dev/null +++ b/config/packages/translation.php @@ -0,0 +1,9 @@ +extension('framework', ['default_locale' => 'en', 'translator' => ['default_path' => '%kernel.project_dir%/translations', 'fallbacks' => ['%locale%']]]); +}; diff --git a/config/packages/translation.yaml b/config/packages/translation.yaml deleted file mode 100644 index eb71fe8..0000000 --- a/config/packages/translation.yaml +++ /dev/null @@ -1,6 +0,0 @@ -framework: - default_locale: 'en' - translator: - default_path: '%kernel.project_dir%/translations' - fallbacks: - - '%locale%' diff --git a/config/packages/twig.php b/config/packages/twig.php new file mode 100644 index 0000000..8c28435 --- /dev/null +++ b/config/packages/twig.php @@ -0,0 +1,9 @@ +extension('twig', ['form_themes' => ['form_custom_layout.html.twig'], 'paths' => ['%kernel.project_dir%/templates'], 'debug' => '%kernel.debug%', 'strict_variables' => '%kernel.debug%', 'exception_controller' => null]); +}; diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml deleted file mode 100644 index 5cda60e..0000000 --- a/config/packages/twig.yaml +++ /dev/null @@ -1,6 +0,0 @@ -twig: - form_themes: ['form_custom_layout.html.twig'] - paths: ['%kernel.project_dir%/templates'] - debug: '%kernel.debug%' - strict_variables: '%kernel.debug%' - exception_controller: null diff --git a/config/packages/validator.php b/config/packages/validator.php new file mode 100644 index 0000000..46beaec --- /dev/null +++ b/config/packages/validator.php @@ -0,0 +1,9 @@ +extension('framework', ['validation' => ['email_validation_mode' => 'html5']]); +}; diff --git a/config/packages/validator.yaml b/config/packages/validator.yaml deleted file mode 100644 index 350786a..0000000 --- a/config/packages/validator.yaml +++ /dev/null @@ -1,8 +0,0 @@ -framework: - validation: - email_validation_mode: html5 - - # Enables validator auto-mapping support. - # For instance, basic validation constraints will be inferred from Doctrine's metadata. - #auto_mapping: - # App\Entity\: [] diff --git a/config/routes.php b/config/routes.php new file mode 100644 index 0000000..07310fe --- /dev/null +++ b/config/routes.php @@ -0,0 +1,11 @@ +controller(BlogController::class) +; +}; diff --git a/config/routes.yaml b/config/routes.yaml deleted file mode 100644 index c3283aa..0000000 --- a/config/routes.yaml +++ /dev/null @@ -1,3 +0,0 @@ -#index: -# path: / -# controller: App\Controller\DefaultController::index diff --git a/config/routes/annotations.php b/config/routes/annotations.php new file mode 100644 index 0000000..894e890 --- /dev/null +++ b/config/routes/annotations.php @@ -0,0 +1,7 @@ +import('../../src/Controller/', 'annotation'); +}; diff --git a/config/routes/annotations.yaml b/config/routes/annotations.yaml deleted file mode 100644 index 59c892d..0000000 --- a/config/routes/annotations.yaml +++ /dev/null @@ -1,3 +0,0 @@ -controllers: - resource: '../../src/Controller/' - type: annotation diff --git a/config/routes/dev/framework.php b/config/routes/dev/framework.php new file mode 100644 index 0000000..b9ea828 --- /dev/null +++ b/config/routes/dev/framework.php @@ -0,0 +1,8 @@ +import('@FrameworkBundle/Resources/config/routing/errors.xml') + ->prefix('/_error'); +}; diff --git a/config/routes/dev/framework.yaml b/config/routes/dev/framework.yaml deleted file mode 100644 index bcbbf13..0000000 --- a/config/routes/dev/framework.yaml +++ /dev/null @@ -1,3 +0,0 @@ -_errors: - resource: '@FrameworkBundle/Resources/config/routing/errors.xml' - prefix: /_error diff --git a/config/routes/dev/twig.yaml b/config/routes/dev/twig.yaml deleted file mode 100644 index 5e415e0..0000000 --- a/config/routes/dev/twig.yaml +++ /dev/null @@ -1,3 +0,0 @@ -#_errors: -# resource: '@TwigBundle/Resources/config/routing/errors.xml' -# prefix: /_error diff --git a/config/routes/dev/web_profiler.php b/config/routes/dev/web_profiler.php new file mode 100644 index 0000000..1a4c167 --- /dev/null +++ b/config/routes/dev/web_profiler.php @@ -0,0 +1,11 @@ +import('@WebProfilerBundle/Resources/config/routing/wdt.xml') + ->prefix('/_wdt'); + + $routingConfigurator->import('@WebProfilerBundle/Resources/config/routing/profiler.xml') + ->prefix('/_profiler'); +}; diff --git a/config/routes/dev/web_profiler.yaml b/config/routes/dev/web_profiler.yaml deleted file mode 100644 index c82beff..0000000 --- a/config/routes/dev/web_profiler.yaml +++ /dev/null @@ -1,7 +0,0 @@ -web_profiler_wdt: - resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml' - prefix: /_wdt - -web_profiler_profiler: - resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml' - prefix: /_profiler diff --git a/config/services.php b/config/services.php new file mode 100644 index 0000000..d5cb950 --- /dev/null +++ b/config/services.php @@ -0,0 +1,37 @@ +parameters(); + $parameters->set('locale', 'en'); + + // 'private' means you cannot fetch services directly from the container via $container->get() + // if you need to do this, you can override this setting on individual services + $services = $configurator->services() + ->defaults() + ->autowire() + ->autoconfigure() + ->private(); + + // makes classes in src/App available to be used as services + // this creates a service per class whose id is the fully-qualified class name + // you can exclude directories or files + // but if a service is unused, it's removed anyway + $services->load('App\\', '../src/*') + ->exclude('../src/{Entity,Repository,Tests}'); + + // controllers are imported separately to make sure they're public + // and have a tag that allows actions to type-hint services + $services->load('App\\Controller\\', '../src/Controller') + ->tag('controller.service_arguments'); + + // Fix wiring of custom CRUD maker class + $services->set(MakeCollectionCrud::class) + ->arg('$doctrineHelper', '@maker.doctrine_helper') + ->arg('$formTypeRenderer', '@maker.renderer.form_type_renderer'); + +}; diff --git a/config/services.yaml b/config/services.yaml deleted file mode 100644 index 4d54fec..0000000 --- a/config/services.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# Learn more about services, parameters and containers at -# https://symfony.com/doc/current/service_container.html -parameters: - locale: en - -services: - # default configuration for services in *this* file - _defaults: - # automatically injects dependencies in your services - autowire: true - # automatically registers your services as commands, event subscribers, etc. - autoconfigure: true - # this means you cannot fetch services directly from the container via $container->get() - # if you need to do this, you can override this setting on individual services - public: false - - # makes classes in src/App available to be used as services - # this creates a service per class whose id is the fully-qualified class name - App\: - resource: '../src/*' - # you can exclude directories or files - # but if a service is unused, it's removed anyway - exclude: '../src/{Entity,Repository,Tests}' - - # controllers are imported separately to make sure they're public - # and have a tag that allows actions to type-hint services - App\Controller\: - resource: '../src/Controller' - tags: ['controller.service_arguments'] - - # add more services, or override services that need manual wiring - # App\Service\ExampleService: - # arguments: - # $someArgument: 'some_value' - - App\Maker\MakeCollectionCrud: - arguments: - '$doctrineHelper': '@maker.doctrine_helper' - '$formTypeRenderer': '@maker.renderer.form_type_renderer' diff --git a/src/Kernel.php b/src/Kernel.php index 8f044a9..256dcf6 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -12,6 +12,8 @@ namespace App; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; +use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\HttpKernel\Kernel as BaseKernel; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; @@ -20,18 +22,28 @@ class Kernel extends BaseKernel { use MicroKernelTrait; - protected function configureContainer(ContainerConfigurator $container): void + protected function configureContainer( + ContainerConfigurator $container, + LoaderInterface $loader, + ContainerBuilder $builder + ): void { + $configDir = $this->getConfigDir(); + $container->import('../config/{packages}/*.yaml'); $container->import('../config/{packages}/' . $this->environment . '/*.yaml'); - $container->import('../config/{services}.yaml'); - $container->import('../config/{services}_' . $this->environment . '.yaml'); + + $container->import('../config/{packages}/*.php'); + $container->import('../config/{packages}/' . $this->environment . '/*.php'); + + $container->import('../config/{services}.php'); + $container->import('../config/{services}_' . $this->environment . '.php'); } protected function configureRoutes(RoutingConfigurator $routes): void { - $routes->import('../config/{routes}/' . $this->environment . '/*.yaml'); - $routes->import('../config/{routes}/*.yaml'); - $routes->import('../config/{routes}.yaml'); + $routes->import('../config/{routes}/' . $this->environment . '/*.php'); + $routes->import('../config/{routes}/*.php'); + $routes->import('../config/{routes}.php'); } }