rfc:streamline-phar-api

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:streamline-phar-api [2008/03/28 14:39] lstrojnyrfc:streamline-phar-api [2008/03/28 15:01] – save temporarily lstrojny
Line 3: Line 3:
 This proposal aims to streamline the Phar API to make it more usable and intuitive.  This proposal aims to streamline the Phar API to make it more usable and intuitive. 
 ===== Concrete change proposals ===== ===== Concrete change proposals =====
 +
 +==== Phar ====
 +=== Modifying Phar archive content ===
 +== Related methods ==
 +  * offsetSet()
 +  * offsetGet()
 +  * offsetExists()
 +  * offsetUnset()
 +== Proposal ==
 +In the current API, every path is represented by a single array index. This is counter intuitive, as a multi-dimensional structure (the archive) is represented as a single dimensional array accessible object. The idea is to change that object to represent every path element (e.g. "bar" in "foo/bar/baz") as a single index. This would be accomplished by letting the DirectoryIterator implement ArrayAccess.
 +== Code ==
 +<code php>
 +$phar = new Phar('test.phar');
 +$phar['path']['to']['file'] = 'test'; // Set content 'test' in path/to/file
 +</code>
 +
 +=== Adding isWritable() method ===
 +== Proposal ==
 +Add an isWritable() method to determine whether an archive can be written or not.
 +== Code ==
 +<code php>
 +$phar = new Phar('test.phar');
 +if ($phar->isWritable()) {
 +    $phar['path']['to']['file'] = "test";
 +}
 +</code>
 +
 +=== Adding createDirectory() ===
 +== Proposal ==
 +Add the method Phar->createDirectory() to explicitly create a new directory. createDirectory() will return another Phar object and takes a dirname (string) as an argument.
 +== Code ==
 +<code php>
 +$phar = new Phar('test.phar');
 +$dir = $phar->createDirectory('foo');
 +$dir['file'] = 'content'; // Set the file 'foo/file' to 'content'
 +</code>
  
 ==== SplFileInfo ==== ==== SplFileInfo ====
rfc/streamline-phar-api.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1