1up-lab / OneupFlysystemBundle

A Flysystem integration for your Symfony projects.
MIT License
634 stars 118 forks source link

Can't use env() in bundle configuration #156

Closed Bukashk0zzz closed 1 year ago

Bukashk0zzz commented 7 years ago

Hi,

I use new Dotenv symfony component. I can't define adapter name using env parameter.

Get error [LogicException] The adapter 'env_UPLOADS_PUBLIC_FLYSYSTEM_ADAPTER_e4fc4c42495a301a782e1f2d4704048f' is not defined.

My config:

oneup_flysystem:
    adapters:
        s3_public:
            awss3v3:
                client: aws.s3.client
                bucket: '%aws.s3.cdn.bucket%'
                prefix: '%env(UPLOADS_PUBLIC_PATH)%'

    filesystems:
        uploads_public:
            adapter: '%env(UPLOADS_PUBLIC_FLYSYSTEM_ADAPTER)%'
            mount: uploads_public
            visibility: public
            disable_asserts: false
Algatux commented 6 years ago

@Bukashk0zzz did you try to use a parameter ?

parameters:
    flysystem_adapter: '%env(UPLOADS_PUBLIC_FLYSYSTEM_ADAPTER)%' <---

oneup_flysystem:
    adapters:
        s3_public:
            awss3v3:
                client: aws.s3.client
                bucket: '%aws.s3.cdn.bucket%'
                prefix: '%env(UPLOADS_PUBLIC_PATH)%'

     filesystems:
        uploads_public:
            adapter: '%flysystem_adapter%' <---
            mount: uploads_public
            visibility: public
            disable_asserts: false`
Bukashk0zzz commented 6 years ago

Yes, I changed all to parameters already, but this workaround not solution for this issue.

drcreazy commented 6 years ago

I have the same story:

        current:
            adapter: '%env(FILESYSTEM_ADAPTER)%' 

The adapter '%env(FILESYSTEM_ADAPTER)%' is not defined.

lisfox1 commented 6 years ago

I tired to use the workaround but I am still getting the problem. Would you be able to explain how does this workaround fix that issues? Does the parameters get process before rest of the config?

I am using symfony 4.0

drcreazy commented 6 years ago

@lisfox1 , I've just separate adapter conf files: project/app/config/config_dev.yml

oneup_flysystem:
    filesystems:
        current:
            adapter: 'dev_adapter'

project/app/config/config_prod.yml

oneup_flysystem:
    filesystems:
        current:
            adapter: 's3_adapter'

I'm not sure that sf4 is used same config approach

FrankGiesecke commented 5 years ago

I get the same error. Did anyone find a solution to get this working with environments instead of separate configuration files?

papelbe commented 5 years ago

I had similar issue with my config due to use %kernel.project_dir% route in my .env file. I solved with resolve env var processor: https://symfony.com/doc/current/configuration/env_var_processors.html

keyFilePath: '%env(resolve:GOOGLE_STORAGE_CLIENT_KEY)%'

Maybe it helps you

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.