简体   繁体   中英

Advantages of using cofigs.ini in PHP and Zend Framework?

Actually, my question is

why we are using configs.ini file in PHP?,

What is the difference between using configs.php and configs.ini?

what is the advantege for using configs.ini file??

Read this SO post:

Quoting main points from Paolo Bergantino 's Answer :

  • Use the file with another language.
  • Human editing of data.
  • Updating the settings.
  • Relationship between setting variables.

Config.ini is easier to modify for non programmers. In a lot of applications, the setting file is the only thing a user has to configure to get the app running.

Ini format is easier than a php array for non technical people.

I too came here looking for an answer to that question. Why are we using ini files to configure a PHP application?

  • I'm not talking about config files for php itself, or for apache or anything else. I'm talking about config files for a PHP application I'm building.
  • I have no intent to let a "non techie" touch it. Whether PHP or ini, I wouldn't even trust a non-techie to know what effect changing the configs would produce.
  • I have no desire to parse my configs into another language. It would probably be meaningless to do so anyway.

The question isn't "what is ini good for?". The question is "why ini when we could use PHP?".

I'm asking the question as someone who would be very comfortable expressing myself in PHP. I find it somewhat restrictive to do things in ini.

My guess at the answer... there is little advantage, if any, in using ini files to configure PHP applications versus configuring your PHP application in it's own language.

At least if I built the framework, I would probably just use config classes, extending an abstract config class, each in a PHP file, each being the configuration for a specific thing, rather than throwing everything into one ini file. Then configs could be autoloaded. It would be second nature to load up a config ( $config = new Application_Config_Secret_Sauce(); or $config = Application_Config_Secret_Sauce::getInstance(); ).

But what do I know?!

We used both. In config.php we had some sensitive date (like gpg passphrases) which we encoded with zend guard. In config.ini we had some options which can be changed by the user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM