Req #66114 [NEW]: Request to add save_ini_file()
| From: | garet at approachfoundation dot org | Date: | Mon, 18 Nov 2013 20:09:08 +0000 |
| Subject: | Req #66114 [NEW]: Request to add save_ini_file() | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-182815@lists.php.net to get a copy of this message | ||
From: garet at approachfoundation dot org
Operating system: Any (FreeBSD)
PHP version: 5.5.6
Package: Unknown/Other Function
Bug Type: Feature/Change Request
Bug description:Request to add save_ini_file()
Description:
------------
---
From manual page: http://www.php.net/function.parse-ini-file
---
Though this is a simple request, I think being able to load and save ini
files of this format will increase application portability in the long
run for many people. If there were also a way to somewhat augment the
parsing schema, to catch other common *nix .conf files, t'would be
pretty nice.
Test script:
---------------
<?php
//Load my own configuration file for the user running this app
$ThisAppnConfig = parse_ini_file('~/.MyApplication');
//Load the global configuration for some package used in this app
$SomeAppConfig = parse_ini_file('/etc/SomeApp/default.conf');
$ThisAppConfig['SomeApp.host']=$SomeAppConfig['host']
$SomeAppConfig['host']=$ThisAppConfig['host'];
//Update the user's settings to be compatible with my app
save_ini_file($SomeAppConfig,'~/.SomePackage');
//Save the old value in case the user needs it
save_ini_file($ThisAppConfig,'~/.ThisPackage');
?>
Expected result:
----------------
After loading and parsing two, standard configuration document, the
developer uses values and may or may not transfer them to/from other
config files with the same format.
At the end, a configuration file is generated from the associative array
supplied.
The only caveat is that on saving, a diff tool should be employed to
align any pre-existing key/values to their same line number. By only
appending new data to the end, we preserve any user-provided comments as
well.
Would also be nice to have similar nesting detection both ways. I,e
providing the following..
Array
(
[first_section] => Array
(
[one] => 1
[five] => 5
[animal] => Dodo bird
)
[second_section] => Array
(
[path] => /usr/local/bin
[URL] => http://www.example.com/~username
)
)
Works as expected to append/replace within a section before falling back
to file append.
Actual result:
--------------
None, feature request.
--
Edit bug report at https://bugs.php.net/bug.php?id=66114&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66114&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66114&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66114&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66114&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66114&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66114&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66114&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66114&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66114&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66114&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66114&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66114&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66114&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66114&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66114&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66114&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66114&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66114&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66114&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66114&r=mysqlcfg