note 125553 added to phar.startbuffering

From: Date: Sun, 29 Nov 2020 14:24:22 +0000
Subject: note 125553 added to phar.startbuffering
Groups: php.notes 
Request: Send a blank email to php-notes+get-215914@lists.php.net to get a copy of this message
To setthe ini key phar.readonly to 0, from a unix shell script, this is possible on the fly it is possible see below. The example given on this page has some issues with quoting: (See conversion to simple quotes) #!/usr/bin/php -d phar.readonly=0 <?php print(ini_get('phar.readonly')); // Must return 0 // make sure it doesn't exist @unlink('brandnewphar.phar'); try { $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); } catch (Exception $e) { echo 'Could not create phar:', $e; } echo 'The new phar has ' . $p->count() . " entries\n"; $p->startBuffering(); $p['file.txt'] = 'hi'; $p['file2.txt'] = 'there'; $p['file2.txt']->compress(Phar::GZ); $p['file3.txt'] = 'babyface'; $p['file3.txt']->setMetadata(42); $p->setStub('<?php function __autoload($class) { include "phar://myphar.phar/" . str_replace("_", "/", $class) . ".php"; } Phar::mapPhar("myphar.phar"); include "phar://myphar.phar/startup.php"; __HALT_COMPILER();'); $p->stopBuffering(); // Test $m = file_get_contents("phar://brandnewphar.phar/file2.txt"); $m = explode("\n",$m); var_dump($m); /* Output: * there **/ ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.156.130 (proxied: 37.167.176.219) ---- Manual Page -- http://php.net/manual/en/phar.startbuffering.php Edit -- https://master.php.net/note/edit/125553 Del: integrated -- https://master.php.net/note/delete/125553/integrated Del: useless -- https://master.php.net/note/delete/125553/useless Del: bad code -- https://master.php.net/note/delete/125553/bad+code Del: spam -- https://master.php.net/note/delete/125553/spam Del: non-english -- https://master.php.net/note/delete/125553/non-english Del: in docs -- https://master.php.net/note/delete/125553/in+docs Del: other reasons-- https://master.php.net/note/delete/125553 Reject -- https://master.php.net/note/reject/125553 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#215914) next »