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

Options in DI extensions do not expect Statement instances #228

dakujem opened this issue Jan 7, 2020 · 1 comment

Options in DI extensions do not expect Statement instances #228

dakujem opened this issue Jan 7, 2020 · 1 comment


Copy link

@dakujem dakujem commented Jan 7, 2020

Version: 3.0.2

I'm struggling with a simple case where I'm loading environment variables and some other stuff into parameters and then using them with extensions, namely session, application, http, tracy, but there might be others as well. I'm not sure whether to file an issue to each of the packages or to this one.

I'm getting this kind of errors:

The option 'http > proxy' expects to be string or Nette\Schema\DynamicParameter, object Nette\DI\Definitions\Statement given.


            proxy:                @env::getArray(TRUSTED_PROXIES_IP)

    proxy: %system.http.proxy%

Using scalar values is not an option. I understand I could use "dynamic parameters" like so:

	'system' => ['http' => ['proxy' => TODO ]]

But then how would I call @env::getArray(TRUSTED_PROXIES_IP) instead of TODO?

Furthermore, how would I instead add dynamic parameters in a NEON config file so that I need not have params in 2 places (NEON config file(s) and PHP config file that instructs Configurator)?

I might be missing something. Thanks for help.

Copy link

@dakujem dakujem commented Jan 8, 2020

Thank you for fast response.

markoph added a commit to remp2020/crm-skeleton that referenced this issue Mar 31, 2022
Environment variable `CRM_LANG` was removed.



- [Kdyby/Translation expects default language to be string type][1].
- From version 3.0, `Nette/DI` returns `Nette\DI\Definitions\Statement`
  instead of string (it used to evaluate method used in config; in our
  case `@environmentConfig::get('CRM_LANG')`).
- `Nette\DI` returns error

  The item 'translation › default' expects to be string, object
  Nette\DI\Definitions\Statement given.` is returned.

This worked in Nette 2.4 because `Nette/DI` resolved parameters (in this
case it called method to load environment variable) and it returned string
to extension DI compiler.


Solution: Removed loading of language from environment (variable
CRM_LANG was removed).

If you run different instances from one code base, it's better to have
different `config.*.neon` files. Which config is loaded is based on env
variable `CRM_ENV`. Check `Crm\ApplicationModule\Core::createContainer`.


Note: We checked alternative extension, but [Contributte/Translation also
expects string parameter][2].



- [Temporarily fixed, but reverted back][3]
- [Options in DI extensions do not expect Statement instances][4]

[3]: nette/di#221 (comment)
[4]: nette/di#228

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

1 participant