rfc:streamline-phar-api
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:streamline-phar-api [2008/03/28 14:53] – save temporarily lstrojny | rfc:streamline-phar-api [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Request for comments: Streamline Phar API ====== | ====== Request for comments: Streamline Phar API ====== | ||
+ | |||
+ | * **Version: | ||
+ | * **Date:** 2008-03-28 | ||
+ | * **Author:** Lars Strojny, based on ideas from Elizabeth M. Smith, Marcus Boerger, Benjamin Schulz | ||
+ | * **Status:** Under development | ||
+ | |||
===== Abstract ===== | ===== Abstract ===== | ||
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 | + | ===== Basic change proposals ===== |
+ | |||
==== Phar ==== | ==== Phar ==== | ||
=== Modifying Phar archive content === | === Modifying Phar archive content === | ||
Line 11: | Line 19: | ||
* offsetUnset() | * offsetUnset() | ||
== Proposal == | == 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 be | + | 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. " |
== Code == | == Code == | ||
<code php> | <code php> | ||
Line 18: | Line 26: | ||
</ | </ | ||
+ | === Adding isWritable() method === | ||
+ | == Proposal == | ||
+ | Add an isWritable() method to determine whether an archive can be written or not. Not being able to write an archive either means it is disabled in the php.ini (see Phar:: | ||
+ | == Code == | ||
+ | <code php> | ||
+ | $phar = new Phar(' | ||
+ | if ($phar-> | ||
+ | $phar[' | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === Adding createDirectory() === | ||
+ | == Proposal == | ||
+ | Add the method Phar-> | ||
+ | == Code == | ||
+ | <code php> | ||
+ | $phar = new Phar(' | ||
+ | $dir = $phar-> | ||
+ | $dir[' | ||
+ | </ | ||
+ | |||
+ | === Adding static create()-factory method == | ||
+ | == Proposal == | ||
+ | Add a static create method to allow the convenient creation of a Phar-archive from the file system. The create()-method will take two arguments. The first argument is a string with the path to the archive. The second argument is a string with the path to the directory containing the files to be added to the archive. create() will return a Phar-object. | ||
+ | == Code == | ||
+ | <code php> | ||
+ | $phar = Phar:: | ||
+ | </ | ||
==== SplFileInfo ==== | ==== SplFileInfo ==== | ||
Line 68: | Line 104: | ||
$file-> | $file-> | ||
</ | </ | ||
+ | |||
+ | ==== DirectoryIterator ==== | ||
+ | === Implement DirectoryIterator === | ||
+ | Let DirectoryIterator implement the ArrayAccess interface. By accessing an array index of a directory iterator, the related SplFileInfo object is returned. | ||
+ | === Code === | ||
+ | <code php> | ||
+ | $iterator = new DirectoryIterator(__DIR__); | ||
+ | $file = $iterator[' | ||
+ | </ | ||
+ | |||
+ | ==== SplFileObject ==== | ||
+ | === Overload getContent()/ | ||
+ | It is necessary to overload getContent()/ | ||
+ | |||
+ | ===== Extended change proposals ===== | ||
+ | ==== SplFileObject ==== | ||
+ | === Rename methods === | ||
+ | == Renamed methods == | ||
+ | * eof() => isEndOfFile() | ||
+ | * fflush() => flush() | ||
+ | * fgetc() => getChar() | ||
+ | * fgetcvs() => getCsv() | ||
+ | * fgets() => getLine() | ||
+ | * fgetss() => getStripped() | ||
+ | * flock() => lock() | ||
+ | * fpassthru() => getRest() | ||
+ | * fseek() => seek() | ||
+ | * fstat() => stat() | ||
+ | * ftell() => getLine() | ||
+ | * ftruncate() => truncate() | ||
+ | * fwrite() => write() | ||
+ | == Proposal == | ||
+ | |
rfc/streamline-phar-api.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1