Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding environment variables, removing unused bootloaders from Kernel #141

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,11 @@
use Spiral\Monolog\Bootloader\MonologBootloader;
use Spiral\Nyholm\Bootloader\NyholmBootloader;
use Spiral\Prototype\Bootloader\PrototypeBootloader;
use Spiral\RoadRunnerBridge\Bootloader as RoadRunnerBridge;
use Spiral\Scaffolder\Bootloader\ScaffolderBootloader;
use Spiral\Tokenizer\Bootloader\TokenizerListenerBootloader;
use Spiral\YiiErrorHandler\Bootloader\YiiErrorHandlerBootloader;

class Kernel extends \Spiral\Framework\Kernel
{
protected const SYSTEM = [];
protected const LOAD = [];
protected const APP = [];

public function defineSystemBootloaders(): array
{
return [
Expand All @@ -35,16 +29,11 @@ public function defineBootloaders(): array
return [
// Logging and exceptions handling
MonologBootloader::class,
YiiErrorHandlerBootloader::class,
Bootloader\ExceptionHandlerBootloader::class,

// Application specific logs
Bootloader\LoggingBootloader::class,

// RoadRunner
RoadRunnerBridge\LoggerBootloader::class,
RoadRunnerBridge\HttpBootloader::class,

// Core Services
Framework\SnapshotsBootloader::class,

Expand All @@ -65,7 +54,6 @@ public function defineBootloaders(): array

// Console commands
Framework\CommandBootloader::class,
RoadRunnerBridge\CommandBootloader::class,
ScaffolderBootloader::class,

// Configure route groups, middleware for route groups
Expand Down
3 changes: 3 additions & 0 deletions installer/Application/Common/resources/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@
</source>
<php>
<env name="DB_CONNECTION" value="sqlite" />
<env name="DB_LOG_QUERY_PARAMETERS" value="true" />
<env name="CYCLE_SCHEMA_CACHE" value="true" />
<env name="QUEUE_CONNECTION" value="sync" />
<env name="CACHE_STORAGE" value="local" />
<env name="APP_ENV" value="testing" />
<env name="TOKENIZER_CACHE_TARGETS" value="true" />
<env name="TELEMETRY_DRIVER" value="null" />
<env name="BROADCAST_DRIVER" value="log" />
<ini name="error_reporting" value="-1"/>
<ini name="memory_limit" value="-1"/>
</php>
Expand Down
2 changes: 2 additions & 0 deletions installer/Module/CycleBridge/Generator/Env.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public function process(Context $context): void
$context->envConfigurator->addGroup(
values: [
'DB_CONNECTION' => 'sqlite',
'DB_LOG_QUERY_PARAMETERS' => false,
'DB_WITH_DATETIME_MICROSECONDS' => false,
],
comment: 'Database',
priority: 13,
Expand Down
20 changes: 16 additions & 4 deletions installer/Module/CycleBridge/resources/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@
'drivers' => [
'sqlite' => new Config\SQLiteDriverConfig(
connection: new Config\SQLite\MemoryConnectionConfig(),
queryCache: true
queryCache: env('DB_QUERY_CACHE', true),
options: [
'logQueryParameters' => env('DB_LOG_QUERY_PARAMETERS', false),
'withDatetimeMicroseconds' => env('DB_WITH_DATETIME_MICROSECONDS', false),
],
),
'pgsql' => new Config\PostgresDriverConfig(
connection: new Config\Postgres\TcpConnectionConfig(
Expand All @@ -62,8 +66,12 @@
user: env('DB_USERNAME', 'postgres'),
password: env('DB_PASSWORD', ''),
),
schema: 'public',
queryCache: true,
schema: env('DB_SCHEMA', 'public'),
queryCache: env('DB_QUERY_CACHE', true),
options: [
'logQueryParameters' => env('DB_LOG_QUERY_PARAMETERS', false),
'withDatetimeMicroseconds' => env('DB_WITH_DATETIME_MICROSECONDS', false),
],
),
'mysql' => new Config\MySQLDriverConfig(
connection: new Config\MySQL\TcpConnectionConfig(
Expand All @@ -73,7 +81,11 @@
user: env('DB_USERNAME', 'root'),
password: env('DB_PASSWORD', ''),
),
queryCache: true,
queryCache: env('DB_QUERY_CACHE', true),
options: [
'logQueryParameters' => env('DB_LOG_QUERY_PARAMETERS', false),
'withDatetimeMicroseconds' => env('DB_WITH_DATETIME_MICROSECONDS', false),
],
),
// ...
],
Expand Down
4 changes: 3 additions & 1 deletion installer/Tests/Module/CycleBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public function getEnvironmentVariables(ApplicationInterface $application): arra
'SAFE_MIGRATIONS' => true,
'CYCLE_SCHEMA_CACHE' => false,
'CYCLE_SCHEMA_WARMUP' => false,
'DB_CONNECTION' => 'sqlite'
'DB_CONNECTION' => 'sqlite',
'DB_LOG_QUERY_PARAMETERS' => false,
'DB_WITH_DATETIME_MICROSECONDS' => false,
];
}
}
Loading