Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.2.6

Bug #20104 write config to stdout
Submitted: 2013-10-23 15:14 UTC
From: drzraf Assigned: pce
Status: Closed Package: Config_Lite (version 0.1.5)
PHP Version: 5.5.4 OS: GNU/Linux
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 32 - 14 = ?

 
 [2013-10-23 15:14 UTC] drzraf (RaphaĆ«l Droz)
Description: ------------ Can't understand how to dump a configuration to the standard output. buildOutputString() is protected and write() uses file_put_contents() which make it unsuitable to write anywhere else than to regular files. Test script: --------------- $config = new Config_Lite(); $config->write('php://stdout', ["test"]); Expected result: ---------------- test Actual result: -------------- PHP Warning: file_put_contents(): Exclusive locks may only be set for regular files in /pear/php/Config/Lite.php on line 212 PHP Stack trace: PHP 1. {main}() /tmp/script.php:0 PHP 2. Config_Lite->write() /tmp/script.php:3 PHP 3. file_put_contents() /pear/php/Config/Lite.php:212 PHP Fatal error: Uncaught exception 'Config_Lite_Exception_Runtime' with message 'failed to write file `php://stdout' for writing.' in /pear/php/Config/Lite.php:213 Stack trace: #0 /tmp/script.php(3): Config_Lite->write('php://stdout', Array) #1 {main} thrown in /pear/php/Config/Lite.php on line 21

Comments

 [2013-10-23 18:08 UTC] pce (Patrick Engel)
-Status: Open +Status: Feedback
Config_Lite implements the magic method __toString, which allows to echo'ing the OutputString by an `echo $config`. $config = new Config_Lite(); $config['key'] = 'Value'; echo $config; `file_put_contents()` allows exclusive locks only to be set for regular files, i'll think about supporting streams.
 [2013-10-24 00:25 UTC] pce (Patrick Engel)
-Status: Feedback +Status: Closed -Assigned To: +Assigned To: pce
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/ Config_Lite 0.2 defaults to no flags. $config = new Config_Lite(); $config->write("php://stdout", array("Answer" => 42));