What is the real purpose of application.ini - php

I am a Zend developer. I just want to know the real purpose of the application.ini file. As far as I understood, it is used to specify the locations of controllers, views, models, modules, session and library files (Acl & VanityUrl) and to Connect to database. Anything else about it? Please help me if you have something else.
Cheers...!!!

Its a Configuration file,
Every configuration to the project is defined in this file in a
specific format.
It handle error display, bootstrap file handling.
All the controller files handling and all the above mentioned in
your question itself.
You can also define the configuration as per server i.e. production
server, development/testing, staging server etc....
All the permission hanlding to any specific functionality is done
here.
Newly installed Plugins in framewirk needs to be registered here in
application.ini file.
Routing is also configured herein application.ini file
I hope above are few of the "something else" points you were looking for... Cheers!!! :)

As you stated, you can use it to configure many aspects of your application through one of the Resource Plugins. In addition, you can configure php.ini options, configure Routes, and set options for your own application.
It is also possible to have an empty application.ini and configure everything in the Bootstrap, but the application.ini file is much easier to read and make changes to than it would be to do all of that in the bootstrap. And with the help of the resource plugins, it is often much easier to configure them in the ini file instead of in code.

Related

Symfony bundle configuration

I've just started working with Symfony and have run into a problem that I'm having a hard time tracking down information about.
I'm trying to create a bundle which has its own configuration file, e.g. configuration for doctrine connections.
All documentation I've found have never mentioned of showed how this can be set. Is it possible?
What I want to solve:
I have a bundle which when installed should handle connection to a secondary database table without any configuration needed from the main application in which the bundle has been integrated. Ultimately the configuration in the bundle should be override-able from the main application.
The bundle should be in the lack for a better work "self contained".
I've found documenation about bundle configuration. But all I've seen mentioned there is if one would like to configure the bundle and not interaction with other components (might have missed something).
tl;dr I want to have a config (e.g. AppBundle/Resources/Config/config.yml) file inside a bundle which can configure things like doctrine.
What i've tried
I've tried placing the configuration inside a config.yml file located in Resources/Config/. But I guess the file is never read.
I think it is not good idea to put something related to configuration right inside your bundle and ruin it's reusability by doing such thing. As far as I understood your task what your really need is to configure second entity manager to manage entities from secondary database when you need them. Same problem and its solution are described in following question: Doctrine 2 - Multiple databases configuration and use
Hope that will help!

How to keep CodIgniter application and config in their own in git repos?

Can anybody tell me what kind of workflow should I follow to keep my application source and configuration tracked in Git? I want to keep my config separate from my source is because there is one config for development, another for production enviroment and, and a third for local testing.
It's not unheard of to have a repo just for configuration files (just make sure that git repo does NOT HAVE PUBLIC ACCESS (so, not github unless you have private repos enabled). You end up with a repo for code, and a repo for configuration files, sometimes maintained by a different team (say, the deployment team).
The problem you have is that as far as I'm aware, git doesn't particularly like having multiple repos at the same level.
I don't know anything about CI, but I think it stores its configuration files in application/config.
Two options I can think of:
You can convert all application/config to a git repo and gitignore that folder from the main development repo.
If converting the whole folder into a repo is not feasible (say, some of the configuration files actually belong to the application repo), maintain a separate repo folder somewhere else in the system and symlink your necessary configuration files to application/config (and gitignore those symlinks in your code repo)
There is no need to use separate Git repositories. CodeIgniter supports the idea of environments:
Developers often desire different system behavior depending on whether an application is running in a development or production environment. For example, verbose error output is something that would be useful while developing an application, but it may also pose a security issue when "live".
The ENVIRONMENT Constant
By default, CodeIgniter comes with the environment constant set to use the value provided in $_SERVER['CI_ENV'], otherwise defaults to 'development'.
Set the CI_ENV environment variable for each server process to tell CodeIgniter which environment you're on. Depending on your stack this could involve using Apache's SetEnv, a shell export, or other mechanism.
Then you can set up environment-specific configuration files:
To create an environment-specific configuration file, create or copy a configuration file in application/config/{ENVIRONMENT}/{FILENAME}.php
For example, to create a production-only config.php, you would:
Create the directory application/config/production/
Copy your existing config.php into the above directory
Edit application/config/production/config.php so it contains your production settings
When you set the ENVIRONMENT constant to ‘production’, the settings for your new production-only config.php will be loaded.
Additionally, you may want to load certain settings directly from the environment, as described by the The Twelve-Factor App. (This isn't something that I've seen people do with CodeIgniter before, but it's a useful idea in general.)
For example, it might make sense to keep API keys or database connection information out of your config files, or to leave development-friendly values in your config files and override them with values loaded from environment variables.
An answer from a similar question will help you, it is answer by SO user #dwilkins.
Mr dwikins answer is simple, clear and effective. He suggest gitignore any conf you don't want, but remember to create "conf.sample" sample file.
Mr #alex-stuckey comment to add README file to guide other team member to use the "sample" file.
The following workflow was used back when i was a system administrator and we made scripts that depended on a config preset.
Basically, the main script was always the same, and the script's actions would depend on a config file that would hang from the master branch as so:
Master
|----Script.py
|----config_template.cfg
From Master we would take a branch that looked like so
Mimulation_machine
|----Script.py
|----simulation.cfg-------------->this was the modified config file
The workflow was to switch to master and create a new branch, that would eventually hold the configuration files. It is important that the branches would never merge back to master though. This may not be the best answer nor the most correct but it worked, and allowed us to switch to different configurations with a simple checkout.
Mind you that is an oversimplified verion of what we really had going on, we had a complex structure made out of gitignores and so.

ZF2 - load configuration from database

I am solving a problem: I have a ZF2 Skeleton application which runs fine, service manager, db adapter, routing, everything is fine. But what I need to solve is how, when or how better load some configuration (settings) from database?
The point is (AFAIK) to have the Zend configs that are not visible nor editable from outside (or let's say via administration). But I need to have the ability to administer many configuration settings - and these should be loaded also on the startup (bootstrap, whatever). These settings could be managing e.g. widgets displaying (let's assume that almost every block on the website is controlled by widget - view helper - and I have to decide - via configuration - whether to display that widget or with what additional settings).
What I would need to help with is how to manage this configuration that will be loaded from DB.
should I merge it with Zend config?
should I load it in module's onBoostrap?
should I use better solution (what)?
I was thinking of having editable PHP config file (that will Zend simply load with other config files) so that administering these settings would lead to reading from and writing to a file but this is really a bad idea as there is possibility of more simultaneous edits for which purposes the database handles this far better.
Your module.php should have a function getConfig() which returns an array. You should be able to modify it in such a way to fetch your config key/values from the database.

Modular Way of Reading/Writing Configurations using Zend2

I want to have a bunch of settings in my module, and they should be writable from the App. Since they're application settings, I thought a table for it would be not very efficient (it would only have one row).
I found the Zend module Zend\Config, which seems to be able to to write config files, which can in turn be used by Zend.
It is advisable to write into the module.config.php? Or into a different file? Can I still load it into the standard module config?
I am pretty new to Zend and this fully modular approach, so I'd like some clarification on that.
You should never write into the module directory itself. Instead, have a data directory, e.g. at the root of your application, and put written configuration files in there.

Magento custom module - where to store includes

I am creating a custom magento module and cant decide the best place to store some config files i require with the module?
Anyone out there suggest the best place for this? Should it be in the root of the module or in with the helpers maybe?
Edit:
Along the same lines as this question: is it acceptable to have a folder in the root of the namespace for the modules for includes that will be shared amongst the modules?
If these files are for configuration, they belong in etc. Think of the etc folder the same way you would a unix/linux/bsd system's etc folder. It's where you put configuration information. Convention is that you should use an XML file to hold your config data, and then load it with
Mage::getConfig()->loadModulesConfiguration('your-xml-name-here.xml')
When you use the loadModulesConfiguration method to load your configuration values, Magento combines XML files for ALL modules in the system into one big tree. This allows other modules you'll write (or others would write) to share the configuration information.
You don't need to do this, but etc is definitely the defined place for any configuration files you want to include with your module. Also, whatever method you're choosing, I'd pick a unique file name (packagename_modulename.xml, packagename_modulename.inc, etc.) to ensure against the slim possibility that someone at Magento might pick your name to use in a future version.
Along the same lines as this question: is it acceptable to have a folder in the root of the namespace for the modules for includes that will be shared amongst the modules?
No, that would not be acceptable. If you want a shared configuration, use the method I mentioned above. If modules need to share other information with each other, they should either do so directly (one module instantiates another module's model) or you should define a central "broker" module that handles all inter-module communication. If you're interested more in the topic, I'd recommend the first few chapters of Meyer's Object-oriented Software Construction. If you can get past the whole "how to implement low level data structures" aspected of old programming books, its a great introduction to what CS people when they say "module".
(it's also worth mentioning that if there are simple configuration values, learning how to use the Magento System Config Admin section is worth it.)
You could probably get away with this, but you're purposely avoiding Magento to do so. Inside a module, make a directory called etc and put an XML config file in it called config.xml. That file will be read and included in the Magento configuration, which means you won't have to try to escape the framework to grab your configuration data. Take a look at the existing files for some examples.
The other benefit to this approach is that the conversion from config XML files to user configuration options (in the admin panel) isn't too difficult (requires minor refactoring), so you can later change your configuration method with ease.
Hope that helps!
Thanks,
Joe

Categories