-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Expression engine doesn't handle expressions inside parameters #9658
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
Comments
Indeed, that's not supported. Parameters are static and should not be expressions. I will see how to raise an exception in this case. |
Please don't. I really need this feature in a multitenant application. Having an app for each tenant uses way to many memory. |
Ah the case with session works partially because that specific session is defined as a service in config.yml. |
Can't your issue be solved by overriding the session service ? |
What about allowing expressions but without access to the container ? Only parameters |
@adrienbrault I don't think this is worth it as you can already use parameter values in a parameter: |
@michelsalib: The session is just one service that needs to be configured on the fly. There are others. e.g framework seecret, remember me key,... |
How about several prod_env switched in app.php by reading the Server variable ? Quick, maybe dirty but afterall that's what you want. Michel Salib De : Miha Vrhovnikmailto:notifications@github.com @michelsalib: The session is just one service that needs to be configured on the fly. There are others. Reply to this email directly or view it on GitHub: |
Having an app per tenant doesn't scale. Just run an app with enabled ZendOptimizer and look at the memory consumed by files in app. The other thing is. upgrading application in such a scenario would be a nightmare |
…n expressions (aitboudad) This PR was merged into the 2.4 branch. Discussion ---------- [ExpressionLanguage] throw exception when parameters contain expressions | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9658 | License | MIT | Doc PR | symfony/symfony-docs#3232 Commits ------- ca123bc [ExpressionLanguage] throw exception when parameters contain expressions
I know this is an old thread. But recently I had to define redundant parameters. I had to define the locale for routes, and the same locales but as an array for a different parameter. e.g parameters:
locale: en|np
supported_locales: [en, np] The This is a whitelabel product I am working on, so these values will be different for different installations. parameters:
locale: en|np
supported_locales: (%locale%).split("|") #don't mind the syntax, you get what I am trying to say here |
@broncha what you could do is having a single parameter defined in the parameters.yml file, and having the DI extension of a bundle set the other one based on the first one. |
@stof yes I could do that. I just mentioned it as an example, and there could be many other cases. That would be a kind of syntatic sugar. |
@michelsalib @fabpot Can you fix this? Environment variables are key for deployment configuration in modern applications (12factor.net). But dumping sensitive information like database passwords, API keys and other access credentials to disk is a security risk in multi-tenant environments. In addition to exposing access credentials in a known location the dumped container can be overwritten with malicious code by anyone using the webserver without even escalating privileges in most cases. It is also a scalability issue. Networked filesystems (NFS, AFS, etc) generally are notoriously bad at negotiating write locks and local storage means a waste of resources if each machine compiles the container for itself. At least there should be a check or path postfix indicating whether the environment variables have changed to avoid running with stale configs. |
@b7kich do you actually have a use case for defining parameters dynamically based on credentials ? This is what this issue is about. If you just want to configure services based on env variables, this is possible in Symfony 3.2 already. anyway, commenting on an issue closed 1 year ago is probably not the best place to discuss your own issue. |
Hi @stof - sorry if I wasn't clear enough or got off on a tangent. I'll check out the 3.2 branch. I use an expression extension to dynamically configure sensitive parameters from environment variables but it could be anything else. I do use the SYMFONY__ env prefix and %% for regular parameters and the expression extension works fine for all my services. Where it doesn't is e.g. the doctrine dbal connection credentials or framework.secret. |
beautiful - env injection works perfectly in 3.2. Thanks for the hint! |
I'm getting _Call to undefined method Symfony\Component\ExpressionLanguage\Expression::_set_state() ..... in /app/var/cache/dev/appDevDebugProjectContainer.php line 8170
When I set up the parameter like:
The line 8170 has the following code.
The service that receives that specific parameter works just fine.
The text was updated successfully, but these errors were encountered: