Req #66114 [Opn->Sus]: Request to add save_ini_file()
| From: | cmb@php.net | Date: | Tue, 20 Aug 2019 20:16:59 +0000 |
| Subject: | Req #66114 [Opn->Sus]: Request to add save_ini_file() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-222330@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66114&edit=1
ID: 66114
Updated by: cmb@php.net
Reported by: garet at approachfoundation dot org
Summary: Request to add save_ini_file()
-Status: Open
+Status: Suspended
Type: Feature/Change Request
Package: Filesystem function related
Operating System: Any (FreeBSD)
PHP Version: 5.5.6
Block user comment: N
Private report: N
New Comment:
This feature (request) requires the RFC process[1]. Feel free to
start it anytime!
[1] <https://wiki.php.net/rfc/howto>
Previous Comments:
------------------------------------------------------------------------
[2013-11-18 20:09:07] garet at approachfoundation dot org
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 this bug report at https://bugs.php.net/bug.php?id=66114&edit=1