I have a base config of my ZF2 application, which is in the following structure of my ZF2 application:
/frontend
/config
/autoload -> (here I have config.php file - which is base config)
/brand -> (here I have config files for my vhosts)
When I need things from my vhosts config I simply do like this:
$this->config()['SomethingGoesHere']
My question here is, when I'm located in my vhost (www.sitename1.com). I would like to access the base config within my vhost, how can I do that guys??
If you want to set different configuration for different virtual-hosts I would not recommend to do it like this. You can set more advanced configuration differently, for example by using environmental variables. You can read more on this here in the documentation chapter: Advanced Configuration Tricks.
The correct solution also totally depends on what variables you are setting and what you want to use them for and where you want to use them. If you provide more details on what you are trying to do (what is in your "base config"?) it would be possible to give a more suitable answer for your needs.
Related
I have several instances of the same platform for different people.
Some of them have different translation files than others according to their specific requests.
For the moment, the files have different names and we distinguish them by the pattern in the module.config.php.
The problem is that we have to update and replace the module.config.php every time we update the code (with GIT) to change the pattern according to the client.
Is there a way to define a constant in a *.local.php file and to be able to access it in module.config.php with ZF2 ?
Thank you in advance for your help!
Update : Thanks to #delboy1978uk.
You can use environment variables either in (for Apache at least) the system-wide apache.conf or httpd.conf, in the virtual host or in the .htaccess file. It will then be accessible by getenv()
we have built a multi environment application over laravel 5 with environment based configurations and views, now the problem arises when we try to use environment based public resources like css, js and images, as they are in public directory and does not recursive merge things like in configurations file. can we somehow control it with environment settings etc.
for example:
I have two domains with almost same functionality but differs in some configuration and design, like for example site_1 shows header navigation links on the top while the site_2 does not show header navigation links in top so we can somehow manage it in the configuration site_1.config.settings.header and set values to on or off.
well as per my understanding you are using multiple environment files which varies deployment to deployment, in larvel you can override enivronment variables from environment files and can use one main environment file to override variables like in .env file you can define the APP_ENV = site_1 and can create new environment file named .site_1.env and override all the environment variables which are different for that deployment.
about the public resources you can do the sort of same alike configuration scheme but as you know these files do not recursive merge so you can create a same file in the public/site_1/filename.ext and when adding these files in your templates you can append the environment name as directory to lookup for those files.
You can use the theme package. Like
Cartalyst Theme
I have the Laravel Administrator Plugin and I set up a setting administrator page that is located in:
app/config/administrator/settings/site.php
The application can store the data, but when i try to get some data in one of my controllers like this:
Config::get('administrator.settings.site')
I can get a returned value... Always null or array 0.
How I can get those configuration values?
Solution:
You can use a file path rather than dot notation for file paths:
Config::get('administrator/settings/site.variable_name');
Some Explanation
Dot notation is used to get variables inside the config array within a file, rather than to denote file paths.
Therefore you can use Config::get('administrator/settings/site.variable_name'); to get $variable_name from administrator/settings/site.php, or ENV_DIR_NAME/administrator/settings/site.php depending on your environment.
Directories within in app/config are read as environments. For example app/development/database.php will work with Config::get('database.whatever') when you're in your "development" environment while app/production/database.php will be read with Config::get('database.whatever') when you're in the "production" environment.
Laravel falls back to the config/config/*.php file when no environment-specific file is present.
Note
I believe that admin package has a config file in app/config/packages/frozennode/administrator/administrator.php which the package would like you to use for it's settings. That should be available using this convention: Config::get('package::file.option');
I ran into a very similar problem when using this Laravel-Excel package.
The solution I needed was slightly different to the solution above. I needed to take advantage of Laravel's config overriding feature to have one config setting for normal execution and a different one for testing. Specifically, I normally wanted Excel files to be stored in storage/excel and I wanted them to be put in storage/testing/excel under testing.
The technique of using a slashed path didn't work because it points to a specific file so didn't respect the different environments:
$directory = Config::get('packages/maatwebsite/excel/export.store.path');
The solution was to use a package prefix so that the config loader would respect the environment:
$directory = Config::get('excel::export.store.path');
I'm not exactly sure where the excel shorthand name comes from but I suspect it's something to do with the Excel facade in the package exposing itself as 'excel'.
I try to create application with back-end and frond-end. The folder structure as follows(only show config file position to explain problem)
+root
|-admin
|-application
|—backend
|—config
|—config.php
|—frontend
|—config
|—config.php
|-system
Using back-end admin panel I try to change config value in both back-end and frond-end config.php value. But I fail to change it in front-end config.php file. I don’t need database based solution for this.
Reading the documentation I got this:
Note: CodeIgniter always tries to load the configuration files for the current environment first. If the file does not exist, the global config file (i.e., the one in application/config/) is loaded. This means you are not obligated to place all of your configuration files in an environment folder − only the files that change per environment.
So based on that information, I think the problem is when you are calling it, maybe a problem with your path.
Our organiziation is running 60+ Symfony 1.4 sites and we are looking to globalize the settings files (settings.yml, app.yml). We'd like to have a simple PHP require in the /config/settings|app.yml files and create site-specific settings in the apps/frontend/config/settings|app.yml files. Implementing this setup with the app.yml is not a problem. Settings from the /config/app.yml combine/merge with the apps/frontend/config/app.yml. When we try to implement the settings.yml, however, the settings are overridden by the apps/frontend/config/settings.yml -- specifically the enabled_modules, which we'd like to be able to have sites merge their own specific modules with the global ones.
The link below has the following verbiage:
"...Some configuration files can be defined in several config/ sub-directories contained in the project directory structure.
When the configuration is compiled, the values from all the different files are merged according to a precedence order:..."
So, I'm assuming merging the settings.yml file values is possible and I'm doing something wrong.
http://www.symfony-project.org/referenc ... on_cascade
I appreciate any help that ya'll can provide. Thanks in advance!!