The SettingsFileGenerator.xml file seems to have two purposes. One is to set the SSO Config and the other is to dynamically replace settings in the PortBindingsMaster.xml for each environment. I am replacing dozens of values in the PortBindingMaster.xml file that don't need to also be stored in the SSO config. Is there a standard way to specify which settings I want to be stored in the SSO config so I don't store a lot of extra values there?
Unfortunately, what you're asking is not directly supported. There a couple of workarounds though.
You can maintain a separate settings file for runtime only settings and use a custom CustomPostDeployTarget task to Exec SSOSettingsFileImport.exe with you runtime settings file.
Or, you can use a set of UpdateSSOConfigItem elements as referenced here: Deploy Configuration Settings into SSO.
Why is the /app/config/parameters.yml file in symfony/symfony-standard .gitignore file? I thought the live (prod) settings of a project are defined in this file.
Yes, settings are defined in that file but it's added to .gitignore file because you don't want to store things like database password or csrf token in version control system as this is data which should be kept secret.
You have parameters.yml.dist file which is meant to keep placeholders for such data and running composer install will check if all data defined in parameters.yml.dist is present in parameters.yml. If not it will as you to provide it.
Check best practices for more info
I was looking to add a separate sub-directory to cache directory for one of the services.
What is a default cache path variable (%cache%) for symfony2?
Wasnt easy to find but its %kernel.cache_dir%
I have an application that requires some per-tenant configuration. What I would like to do is load configuration for specific bundles using parameters embedded in the route:
Route: /{tenantId}/some/resource/390234
where I can then load a configuration specific to $tenantId.
As far as I know this is not possible, since configuration loading in symfony2 happens on compile time.
This means every time you do a
php app/console cache:clear
or cache warmup.
Why not do this via configuration entries via database? As an alternative, use a custom class to load e.g. yaml files (don't forget caching) with your own configuration.
This appears to be the scariest topic relating to Symfony2, as after a week of searching and testing, I am still unable to find an answer to this.
In short, I am building an application that will have several subdomains, and I would like a different configuraton for all of them, while sharing multiple bundles from /src, and more importantly, import central config and routes (As well as each app's own)
I went down the road of creating individual /app directories, AppKernal.php files and bootstrap files. The main issue with this is detailed in another question, which has recieved no answers (not that I blame anyone TBH :D).
Symfony2 multiple config and routing files for subdomain routing
I have found discussion on the matter, Fabian even takes part in this:
https://groups.google.com/forum/?fromgroups=#!topic/symfony-devs/yneojUuFiqw
And this discussion on a PR to github to provide support in version 2.2 (still 6mo away I hear)
https://github.com/symfony/symfony/pull/3378
Is there anyone out there who has done this before? Is the process easy enough to explain? Is there any information available to assist with this?
I'm pretty much at the stage where it appears this simply is not possible. Which I find really strange for a system as touted as Symfony, especially when it appears Symfony1.4 did this rather easily.
Update
Thanks for your responses. The challenge is, there is a hierarchy of configs. These configs in turn import their own routing.yml files.
For instance: the domain http://testing.api.mydomain.com would include the following configs:
config_api.yml -> config_testing.yml -> config_dev.yml -> config.yml
All import their own routing.yml file. But only the one in config_api.yml is loaded. It seems framework: router: config option overrides previous usages in other config files, rather than extends.
In all fairness, the location of the app code is inconsequential. Having a hierarchical configuration with hierarchical routes seems to be the gotacha.
Cheers
Multiple applications projects can be achieved by splitting your code in multiple Kernels.
You can then benefit:
multiple web roots (useful for differents domains)
shared & specific config (via imports)
clean separation of Bundles...
I have described the whole process here: http://jolicode.com/blog/multiple-applications-with-symfony2 and you can find an example distribution here: https://github.com/damienalexandre/symfony-standard
Sorry for necroing...
I just want to say that I have looked into multiple application structure for Symfony2 as well. Since version 2.4, when routing supported hostname based routing, there has been no need for multiple apps.
All you now need to do is separate your "apps" into different bundles, say AcmeSiteBundle and AcmeApiBundle, then in app/config/routing.yml:
acme_site:
host: "www.{domain}"
resource: "#AcmeSiteBundle/Resources/config/routing.yml"
prefix: /
defaults:
domain: "%domain%"
requirements:
domain: "%domain%"
acme_api:
host: "api.{domain}"
resource: "#AcmeApiBundle/Resources/config/routing.yml"
prefix: /
defaults:
domain: "%domain%"
requirements:
domain: "%domain%"
Remember to have domain parameter set in app/config/parameters.yml
parameters:
.....
domain: example.com
You can create different configuration using the testing/Dev example :
Step 1
Create as many web/app.php file as you have subdomain.
web/app_subdomainx.php
Step 2
In each app_subdomain_X.php file change configuration :
$kernel = new AppKernel('subdomainx', false);
Step 3
create configuration file matching your environment
config_subdomainx.yml
security_subdomainx.yml
Step 4
acces you specific domain through
/web/app_subdomainx.php
PS :
Keep config.yml for common configuration (like db connection) and include config.yml into config_subdomainx.yml
imports:
- { resource: config.yml }
you can try to find something on github. I've found the following Bundle which should do this. Imikay RouterBundle
Basically Fabien is right, there's no reason to have more than one application, if you really have a need for a different application it's probably a different project. Bundles and libraries can be easily shared like any other bundle you see on the web.
Then you can have the small part of the set up belonging to each thing you call "app" in the app part of each project.
If they share the entirety of the code then it's just a matter of configuration hierarchy for each sub-domain, which could be your case considering you want to share some part of the config.
Symfony has many ways of allowing you to reutilise code which are very nice, but the framework is not meant to have many applications, if you want to try to hack it, go ahead, but then you're not using the framework anymore. And that's why you can't find examples, not because it's scary, it'd not be that hard to modify, it'd just be ugly, IMO.
Maybe you can try this bundle, that handle multiple domain website on same app and database:
https://github.com/AppVentus/MultiDomainBundle.