8000 How to use with a custom runtime (that also extends SymfonyRuntime) · Issue #56 · brefphp/symfony-bridge · GitHub
[go: up one dir, main page]

Skip to content
How to use with a custom runtime (that also extends SymfonyRuntime) #56
Closed
@allan-simon

Description

@allan-simon

I have a custom runtime that is like this

<?php                                                                                                     
                                                                                                                                
declare(strict_types=1);                                                                                  
                                                                                                                                         
namespace App\Runtime;                                                                                                                        
                                                                                                                                                       
use App\Config\KmsDotEnvLoader;                                                                           
use Symfony\Component\Dotenv\Dotenv;                                                                                                                        
use Symfony\Component\Runtime\SymfonyRuntime;                                                              
                                                                                                                 
class SymfonyWithKMSRuntime extends SymfonyRuntime                                                                                                                                                      
{
    /**
     * {@inheritdoc}
     *
     * @param array<mixed> $options                                                                                                                        
     */
    public function __construct(array $options = [])
    {
        parent::__construct($options);
        $kmsDotEnvLoader = new KmsDotEnvLoader(new Dotenv());
        $kmsDotEnvLoader->inject(\dirname(__DIR__).'/../'.KmsDotEnvLoader::ENCRYPTED_FILE);
    }
}

i.e it reads additional env variables from a kms-encrypted file

however if i try to use the version 0.2.0 wihtout php-fpm, it fails because the BrefRuntime is hardcoded.

Is there a way to do what I want with the bref/symfony-bridge as it is ? (i.e to get the env variables set-up, I don't mind not using 'my' runtime, as long as the job is done)

I got it working by moving this piece of code in the constructor of my kernel, but it degrades a lot the performance ( I think because now it needs to read the configuration at every request and not only cold ones ? )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0