Skip to content

Commit

Permalink
Update config with PHP files
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurJCQ committed Feb 12, 2024
1 parent 0cbdced commit 90f226e
Show file tree
Hide file tree
Showing 29 changed files with 394 additions and 318 deletions.
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions config/packages/cache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $frameworkConfig): void {
$frameworkConfig->cache()->app('cache.adapter.apcu');
};
19 changes: 0 additions & 19 deletions config/packages/cache.yaml

This file was deleted.

78 changes: 78 additions & 0 deletions config/packages/doctrine.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

declare(strict_types=1);

use App\Domain\Mission\Entity\Mission;
use App\Domain\Player\Entity\Player;
use App\Domain\Room\Entity\Room;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Config\DoctrineConfig;
use Symfony\Config\FrameworkConfig;

return static function (
DoctrineConfig $doctrineConfig,
FrameworkConfig $frameworkConfig,
ContainerConfigurator $containerConfigurator,
): void {
$doctrineConfig->dbal()->defaultConnection('default');
$dbalConfig = $doctrineConfig->dbal()->connection('default');

$dbalConfig
->url('%env(resolve:DATABASE_URL)%')
->profilingCollectBacktrace('%kernel.debug%');

$doctrineConfig->orm()->defaultEntityManager('default');
$entityManagerConfig = $doctrineConfig->orm()
->autoGenerateProxyClasses(true)
->enableLazyGhostObjects(true)
->entityManager('default');

$entityManagerConfig
->reportFieldsWhereDeclared(true)
->validateXmlMapping(true)
->namingStrategy('doctrine.orm.naming_strategy.underscore_number_aware')
->autoMapping(true);

$entityManagerConfig->mapping(Room::class)
->type('attribute')
->isBundle(false)
->dir('%kernel.project_dir%/src/Domain/Room/Entity')
->prefix('App\Domain\Room\Entity')
->alias('App\Domain\Room');

$entityManagerConfig->mapping(Player::class)
->type('attribute')
->isBundle(false)
->dir('%kernel.project_dir%/src/Domain/Player/Entity')
->prefix('App\Domain\Player\Entity')
->alias('App\Domain\Player');

$entityManagerConfig->mapping(Mission::class)
->type('attribute')
->isBundle(false)
->dir('%kernel.project_dir%/src/Domain/Mission/Entity')
->prefix('App\Domain\Mission\Entity')
->alias('App\Domain\Mission');

if ($containerConfigurator->env() === 'test') {
$dbalConfig->url('%env(resolve:DATABASE_URL_TEST)%');
}

if ($containerConfigurator->env() !== 'prod') {
return;
}

$doctrineConfig->orm()
->autoGenerateProxyClasses(false)
->proxyDir('%kernel.build_dir%/doctrine/orm/Proxies');

$entityManagerConfig->queryCacheDriver()
->type('pool')
->pool('doctrine.system_cache_pool');
$entityManagerConfig->resultCacheDriver()
->type('pool')
->pool('doctrine.result_cache_pool');

$frameworkConfig->cache()->pool('doctrine.result_cache_pool')->adapters(['cache.app']);
$frameworkConfig->cache()->pool('doctrine.system_cache_pool')->adapters(['cache.system']);
};
62 changes: 0 additions & 62 deletions config/packages/doctrine.yaml

This file was deleted.

10 changes: 10 additions & 0 deletions config/packages/doctrine_migrations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

use Symfony\Config\DoctrineMigrationsConfig;

return static function (DoctrineMigrationsConfig $doctrineMigrationsConfig): void {
$doctrineMigrationsConfig->migrationsPath('DoctrineMigrations', '%kernel.project_dir%/migrations');
$doctrineMigrationsConfig->enableProfiler(false);
};
6 changes: 0 additions & 6 deletions config/packages/doctrine_migrations.yaml

This file was deleted.

22 changes: 22 additions & 0 deletions config/packages/framework.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $frameworkConfig, ContainerConfigurator $containerConfigurator): void {
$frameworkConfig->secret('%env(APP_SECRET)%');
$frameworkConfig->csrfProtection()->enabled(false);
$frameworkConfig->annotations()->enabled(false);
$frameworkConfig->httpMethodOverride(false);
$frameworkConfig->handleAllThrowables(true);
$frameworkConfig->session()->enabled(false);
$frameworkConfig->phpErrors()->log(true);

if ($containerConfigurator->env() !== 'test') {
return;
}

$frameworkConfig->test(true);
};
26 changes: 0 additions & 26 deletions config/packages/framework.yaml

This file was deleted.

13 changes: 13 additions & 0 deletions config/packages/lexik_jwt_authentication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

use Symfony\Config\LexikJwtAuthenticationConfig;

return static function (LexikJwtAuthenticationConfig $lexikJwtAuthenticationConfig): void {
$lexikJwtAuthenticationConfig
->secretKey('%env(resolve:JWT_SECRET_KEY)%')
->publicKey('%env(resolve:JWT_PUBLIC_KEY)%')
->passPhrase('%env(JWT_PASSPHRASE)%')
->tokenTtl(2628288);
};
6 changes: 0 additions & 6 deletions config/packages/lexik_jwt_authentication.yaml

This file was deleted.

26 changes: 26 additions & 0 deletions config/packages/mercure.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Config\MercureConfig;

return static function (MercureConfig $mercureConfig, ContainerConfigurator $containerConfigurator): void {
$defaultHub = $mercureConfig->hub('default');
$defaultHub
->url('%env(MERCURE_URL)%')
->publicUrl('%env(MERCURE_PUBLIC_URL)%');

$jwtConfig = $defaultHub->jwt();
$jwtConfig
->secret('%env(MERCURE_JWT_SECRET)%')
->publish('*')
->subscribe('*');

if ($containerConfigurator->env() !== 'test') {
return;
}

$defaultHub->url('mercure')->publicUrl('public-mercure');
$jwtConfig->secret('secret')->publish('*');
};
18 changes: 0 additions & 18 deletions config/packages/mercure.yaml

This file was deleted.

67 changes: 67 additions & 0 deletions config/packages/monolog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Config\MonologConfig;

return static function (MonologConfig $monologConfig, ContainerConfigurator $containerConfigurator): void {
$monologConfig->channels(['deprecation']);

if ($containerConfigurator->env() === 'dev') {
$monologConfig->handler('main')
->type('stream')
->path('%kernel.logs_dir%/%kernel.environment%.log')
->level('debug')
->channels(['elements' => ['!event']]);

$monologConfig->handler('console')
->type('console')
->processPsr3Messages(false)
->channels(['elements' => ['!event', '!doctrine', '!console']]);
}

if ($containerConfigurator->env() === 'test') {
$mainHandler = $monologConfig->handler('main')
->type('fingers_crossed')
->actionLevel('error')
->handler('nested');

$mainHandler->channels(['elements' => ['!event']]);
$mainHandler->excludedHttpCode()->code(404);
$mainHandler->excludedHttpCode()->code(405);

$monologConfig->handler('nested')
->type('stream')
->path('%kernel.logs_dir%/%kernel.environment%.log')
->level('debug');
}

if ($containerConfigurator->env() !== 'prod') {
return;
}

$mainHandler = $monologConfig->handler('main')
->type('fingers_crossed')
->actionLevel('error')
->bufferSize(50)
->handler('nested');

$mainHandler->excludedHttpCode([404, 405]);

$monologConfig->handler('nested')
->type('rotating_file')
->path('%kernel.logs_dir%/%kernel.environment%.log')
->level('info')
->maxFiles(10);

$monologConfig->handler('console')
->type('console')
->processPsr3Messages(false)
->channels(['elements' => ['!event', '!doctrine']]);

$monologConfig->handler('deprecation')
->type('stream')
->path('php://stderr')
->channels(['elements' => ['deprecation']]);
};
Loading

0 comments on commit 90f226e

Please sign in to comment.