bzikarsky / gelf-php

A php implementation to send log-files to a gelf compatible backend like graylog
MIT License
409 stars 85 forks source link

How to pass SslOptions to HttpTransport via Symfony service definition? #126

Closed thomaskonrad closed 3 years ago

thomaskonrad commented 4 years ago

I have defined my Gelf Symfony services as follows:

services:
    Gelf\Publisher:
        arguments:
            - '@Gelf\Transport\HttpTransport'
    Gelf\Transport\HttpTransport:
        arguments:
            - '%env(GRAYLOG_HOSTNAME)%'
            - '%env(GRAYLOG_PORT)%'
            - '%env(GRAYLOG_PATH)%'
            # This is where the `SslOptions` object would go.

The HttpTransport constructor looks like this:

 public function __construct(
        $host = self::DEFAULT_HOST,
        $port = self::DEFAULT_PORT,
        $path = self::DEFAULT_PATH,
        SslOptions $sslOptions = null
    ) {

How can I pass an SslOptions object here via the service definition? The class has no constructor, so I cannot simply use it as a service. Do I have to override SslOptions, make a service out of it, and pass the options to the constructor? Or what's the default way of specifying SSL options with this library?

bzikarsky commented 3 years ago

Sorry, for the late answer. My open-source projects lack a bit of support currently.

If it still matters: This is more a question for Symfony, or their DI component to be specific. I'd suggest that you have SslOptions in the DIC and configure it there accordingly.