files
object
%CSV
/phlo/resources/files/CSV.phlo
static
CSV :: __handle
line 8
CSV::$__handle is een verwijzing naar de bestandshandle die wordt gebruikt voor het lezen of schrijven van CSV-gegevens op de opgegeven locatie en bestandsnaam.
"CSV/$path$filename"method
%CSV -> __construct (string $filename, ?string $path = null)
line 9
Initialiseert een CSV-object door het pad van het bestand te construeren op basis van de gegeven bestandsnaam en optioneel pad, standaard ingesteld op 'data'. Als het geconstrueerde bestand leesbaar is, roept het de objRead-methode aan om de CSV-gegevens te lezen.
$path ??= data
$this->objFile = $path.strtr($filename, [slash => dot]).'.csv'
if (is_readable($this->objFile)) $this->objRead()readonly
%CSV -> objFile:string
line 15
Converteert een CSV-bestand naar een obj-representatie voor eenvoudigere manipulatie binnen Phlo.
static
CSV :: row (array $values, string $separator = comma):string
line 19
One line: each value quoted, and text a spreadsheet would run as a formula made inert.
implode($separator, array_map(fn($v) => dq.str_replace(dq, dq.dq, !is_numeric($v) && !preg_match('/^[+-]?\d[\d.,]*$/', (string)$v) && preg_match('/^[=+\-@\t\r]/', (string)$v) ? sq.$v : (string)$v).dq, $values)).nlstatic
CSV :: text (iterable $rows, ?array $header = null, string $separator = comma):string
line 22
Rows as text, the keys of the first row as the header unless $header names it.
$out = void
foreach ($rows AS $row){
$row = (array)($row instanceof obj ? $row->objData : $row)
if ($out === void && ($header ??= array_keys($row)) !== []) $out = static::row($header, $separator)
$out .= static::row(array_values($row), $separator)
}
return $out === void && $header ? static::row($header, $separator) : $outstatic
CSV :: download (iterable $rows, string $filename, ?array $header = null, string $separator = comma)
line 32
output("\u{FEFF}".static::text($rows, $header, $separator), $filename, true, type: 'text/csv; charset=utf-8')method
%CSV -> objRead:void
line 34
Leest een CSV-bestand en converteert de inhoud naar een associatieve array van objecten, waarbij de eerste rij als headers wordt gebruikt.
$fp = fopen($this->objFile, 'r+')
$headers = str_replace([dq, cr, lf], void, fgets($fp))
$delimiter = substr_count($headers, comma) > substr_count($headers, semi) ? comma : semi
$headers = explode($delimiter, $headers)
while ($row = fgetcsv($fp, null, $delimiter, dq, void)) $this->objData[] = array_combine($headers, $row)
fclose($fp)object
%DOCX
/phlo/resources/files/DOCX.phlo
method
%DOCX -> __construct (string $file)
line 9
$zip = new ZipArchive()
if ($zip->open($file) !== true) error('DOCX: cannot open '.basename($file))
$xml = $zip->getFromName('word/document.xml')
$zip->close()
if (!$xml) error('DOCX: no document.xml in '.basename($file))
$text = preg_replace('/<\/w:p>/', lf, $xml)
$text = strip_tags($text)
$text = html_entity_decode($text, ENT_QUOTES | ENT_XML1, 'UTF-8')
$this->text = trim(preg_replace('/[ \t]+/', space, $text))
$this->paragraphs = array_values(array_filter(explode(lf, $this->text), fn($p) => trim($p) !== void))static
DOCX :: toText (string $file):string
line 22
Converteert de inhoud van een DOCX-bestand naar platte tekst.
(new static($file))->textobject
%file
/phlo/resources/files/file.phlo
static
file :: __handle
line 9
Deze expressie bouwt een bestandspad door 'file/$file' te concatenateren met de optionele naam, indien opgegeven.
"file/$file".($name ? "/$name" : void)method
%file -> __construct (public string $file, ?string $name = null, $contents = null, ...$args)
line 10
Initialiseert een bestandsobject met een opgegeven bestandsnaam, een optionele naam en optionele inhoud, en staat ook extra argumenten voor objectimport toe.
$name && $this->name = $name
is_string($contents) && $this->write($contents)
$args && $this->objImport(...$args)method
%file -> append (string $data):int|false
line 16
Voegt de opgegeven stringgegevens toe aan het einde van het bestand, met exclusieve toegang tijdens de bewerking.
file_put_contents($this->file, $data, FILE_APPEND | LOCK_EX)prop
%file -> basename:string
line 17
Geeft de basisnaam van het bestand terug vanuit het opgegeven bestandspad.
pathinfo($this->file, PATHINFO_BASENAME)method
%file -> base64:string
line 18
Codet de inhoud van een bestand naar een Base64-string.
base64_encode($this->contents)method
%file -> contents:string|false
line 19
Leest de volledige inhoud van een bestand in een string.
file_get_contents($this->file)method
%file -> contentsINI (bool $parse = true):array|false
line 20
Leest de inhoud van een bestand en parseert het als een INI-string, waarbij een associatieve array wordt geretourneerd. De parameter $parse bepaalt of er getypeerde of ruwe scanning voor de INI-gegevens moet worden gebruikt.
parse_ini_string($this->contents, true, $parse ? INI_SCANNER_TYPED : INI_SCANNER_RAW)method
%file -> contentsJSON ($assoc = null)
line 21
Decodeert de JSON-string die is opgeslagen in de inhouds-eigenschap naar een PHP-variabele, waarbij optioneel een associatieve array wordt geretourneerd als de $assoc-parameter op true is ingesteld.
json_decode($this->contents, $assoc)method
%file -> copy ($to):bool
line 22
Kopieert het bestand dat door het huidige object wordt vertegenwoordigd naar het opgegeven bestemmingspad.
copy($this->file, $to)method
%file -> created:int|false
line 23
Geeft de Unix-tijdstempel van de laatste keer dat het bestand is aangemaakt.
filectime($this->file)method
%file -> createdAge:int
line 24
Geeft de leeftijd van het bestand op basis van de aanmaakdatum.
age($this->created)method
%file -> createdHuman:string
line 25
Geeft een leesbare weergave van de creatietijd van het bestand.
time_human($this->created)method
%file -> curl ($type = null, $filename = null):CURLFile
line 26
Maakt een nieuw CURLFile-object voor bestandsuploads in een cURL-verzoek, waarmee het bestandstype en de bestandsnaam kunnen worden opgegeven.
new CURLFile($this->file, $type, $filename)method
%file -> delete:bool
line 27
Verwijdert het opgegeven bestand als het bestaat en retourneert een debugbericht dat het succes of falen van de bewerking aangeeft.
first($deleted = $this->exists && unlink($this->file), debug($deleted ? "Deleted $this->basename" : "Could not delete $this->basename"))method
%file -> exists:bool
line 28
Controleert of het opgegeven bestand bestaat in het bestandssysteem.
file_exists($this->file)prop
%file -> ext:string
line 29
Haal de bestandsextensie op uit de bestandsnaam die is opgeslagen in de 'name' eigenschap met behulp van de PHP-functie pathinfo.
pathinfo($this->name, PATHINFO_EXTENSION)prop
%file -> filename:string
line 30
Haalt de bestandsnaam op uit het bestandspad dat is opgeslagen in de 'file' eigenschap.
pathinfo($this->file, PATHINFO_FILENAME)method
%file -> getLine:string|false
line 31
Haalt een enkele regel op van een bestandspointer, retourneert false bij mislukking of de regel zonder afsluitende spaties bij succes.
($line = fgets($this->pointer)) === false ? false : rtrim($line)method
%file -> getLength (int $length):string|false
line 32
Haal de lengte van het bestand op door een bepaald aantal bytes van de bestandspointer te lezen.
fread($this->pointer, $length)method
%file -> is (string $file):bool
line 33
Controleert of het opgegeven bestand overeenkomt met de huidige bestandsinstantie.
$file === $this->filemethod
%file -> md5:string|false
line 34
Berechnet de MD5-hash van het opgegeven bestand.
md5_file($this->file)prop
%file -> mime:string
line 35
Geeft het MIME-type van het bestand op basis van de naam.
mime($this->name)method
%file -> modified:int|false
line 36
Geeft de laatste wijzigingstijd van het opgegeven bestand terug als een Unix-tijdstempel.
filemtime($this->file)method
%file -> modifiedAge:int
line 37
Geeft de leeftijd van het bestand op basis van de laatste wijzigingstijdstempel.
age($this->modified)method
%file -> modifiedHuman:string
line 38
Geeft een leesbare weergave van de laatste wijzigingstijd van het bestand.
time_human($this->modified)method
%file -> move ($to):bool
line 39
Verplaatst het huidige bestand naar een nieuwe locatie die is opgegeven door $to en werkt de bestandsverwijzing bij bij succes.
rename($this->file, $to) && $this->file = $toprop
%file -> name:string
line 40
Dit haalt de basename van het bestand dat door het object wordt vertegenwoordigd, wat de naam van het bestand zonder pad is.
$this->basenamemethod
%file -> output ($download = false)
line 41
Geeft de inhoud van een bestand weer, met de optie om het te downloaden indien opgegeven.
output($this->contents, $this->name, $download)prop
%file -> path:string
line 42
Dit haalt het pad van de map van het opgegeven bestand op en voegt er een schuine streep aan toe.
realpath(pathinfo($this->file, PATHINFO_DIRNAME)).slashprop
%file -> pathRel:string
line 43
Deze expressie retourneert het relatieve pad van een bestand door te controleren of het bestandspad begint met 'app' en, indien dit het geval is, die prefix te verwijderen; anders retourneert het het oorspronkelijke bestandspad.
str_starts_with($this->file, app) ? substr($this->file, strlen(app)) : $this->fileprop
%file -> pointer
line 44
Opent het opgegeven bestand in lees- en schrijfmodes en retourneert een pointer naar de bestandsresource.
fopen($this->file, 'r+')method
%file -> readable:bool
line 45
Controleert of het opgegeven bestand leesbaar is.
is_readable($this->file)method
%file -> src:string
line 46
Deze expressie genereert een data-URI voor een bestand, waarbij het MIME-type en de base64-gecodeerde inhoud worden gecombineerd.
"data:$this->mime;base64,$this->base64"method
%file -> size:int|false
line 47
Geeft de grootte van het opgegeven bestand in bytes terug.
filesize($this->file)method
%file -> sizeHuman (int $precision = 0):string
line 48
Converteert een bestandsgrootte in bytes naar een leesbaar formaat, met een optionele precisie voor decimalen.
size_human($this->size, $precision)method
%file -> sha1:string|false
line 49
Berechnet de SHA-1-hash van het opgegeven bestand.
sha1_file($this->file)method
%file -> shortenTo (int $length):string
line 50
Verkort de bestandsnaam tot een opgegeven lengte terwijl de bestandsextensie behouden blijft, met toevoeging van een ellips als de naam wordt ingekort.
strlen($this->name) <= $length ? $this->name : substr($this->name, 0, $length - strlen($this->ext) - 3).dot.dot.dot.$this->extmethod
%file -> title:string
line 51
Haalt de titel uit de bestandsnaam door deze om te zetten naar een leesbaar formaat, waarbij underscores worden vervangen door spaties en de eerste letter wordt gecapitaliseerd.
ucfirst(strtr(pathinfo($this->name, PATHINFO_FILENAME), [us => space]))method
%file -> token ($length = 20):string
line 52
Genereert een token van de opgegeven lengte met behulp van SHA-1 hashing.
token($length, $this->sha1)method
%file -> type:string
line 53
Haalt het type van een bestand uit de MIME-type door de substring voor de eerste slash op te halen.
substr($this->mime, 0, strpos($this->mime, slash))method
%file -> touch:bool
line 54
Maakt een nieuw bestand aan of werkt de tijdstempel van een bestaand bestand bij dat door het bestandspad is opgegeven.
touch($this->file)method
%file -> writable:bool
line 55
Controleert of het opgegeven bestand schrijfbaar is.
is_writable($this->file)method
%file -> writeINI ($data, bool $deleteEmpty = false):bool
line 56
Schrijft gegevens naar een INI-bestandsformaat. De optionele parameter staat het verwijderen van lege secties toe als deze op true is ingesteld.
$this->write(!$deleteEmpty || $data ? loop($data, fn($value, $key) => $key.' = '.dq.strtr($value, [dq => bs.dq, lf => '\n']).dq, lf).lf : void, $deleteEmpty)method
%file -> writeJSON ($data, bool $deleteEmpty = false):bool
line 57
$this->write(!$deleteEmpty || $data ? json_encode($data, jsonPretty) : void, $deleteEmpty)method
%file -> writeJSONplain ($data, bool $deleteEmpty = false):bool
line 58
Schrijft de opgegeven gegevens als een JSON-string naar een bestand, met de optie om lege vermeldingen te verwijderen op basis van de deleteEmpty-vlag.
$this->write(!$deleteEmpty || $data ? json_encode($data) : void, $deleteEmpty)method
%file -> write (string $data, bool $deleteEmpty = false):bool
line 59
Schrijft de opgegeven stringgegevens naar een bestand, met de optie om het bestand te verwijderen als de gegevens leeg zijn.
if (!$data && $deleteEmpty) return $this->delete
if ($written = file_put_contents($this->file, $data, LOCK_EX) !== false) debug('Written '.$this->basename.' ('.$this->sizeHuman.')')
else error('Could not write '.$this->file)
return $writtenmethod
%file -> objInfo:array
line 66
Maakt een object aan met informatie over een bestand, inclusief de naam, het bestaan, en optioneel de grootte, aanmaakdatum, wijzigingsdatum en MIME-type als het bestaat.
array_combine($keys = array_merge(['file', 'name', 'exists'], $this->exists ? ['sizeHuman', 'createdHuman', 'modifiedHuman', 'mime'] : []), loop($keys, fn($arg) => $this->$arg))object
%ICS
/phlo/resources/files/ICS.phlo
static
ICS :: text (iterable $events, string $name = void):string
line 8
$lines = ['BEGIN:VCALENDAR', 'VERSION:2.0', 'PRODID:-//Phlo//ICS//EN', 'CALSCALE:GREGORIAN', ...($name === void ? [] : ['X-WR-CALNAME:'.static::escape($name)])]
foreach ($events AS $event) array_push($lines, ...static::event((array)($event instanceof obj ? $event->objData : $event)))
$lines[] = 'END:VCALENDAR'
return implode(nl, array_map([static::class, 'fold'], $lines)).nlstatic
ICS :: download (iterable $events, string $filename, string $name = void)
line 15
output(static::text($events, $name), filename: $filename, attachment: true, type: 'text/calendar; charset=utf-8')static
ICS :: feed (iterable $events, string $name = void)
line 17
output(static::text($events, $name), type: 'text/calendar; charset=utf-8')static
ICS :: event (array $event):array
line 19
$start = is_numeric($event['start']) ? (int)$event['start'] : strtotime((string)$event['start'])
$end = isset($event['end']) ? (is_numeric($event['end']) ? (int)$event['end'] : strtotime((string)$event['end'])) : null
$allDay = !empty($event['allDay'])
$write = fn($key, $time) => $allDay ? "$key;VALUE=DATE:".date('Ymd', $time) : "$key:".gmdate('Ymd\THis\Z', $time);
$text = fn($key, $field) => isset($event[$field]) && (string)$event[$field] !== void ? [$key.colon.static::escape((string)$event[$field])] : [];
return [
'BEGIN:VEVENT',
'UID:'.static::single((string)($event['uid'] ?? md5($event['title'].$start))).'@'.host,
'DTSTAMP:'.gmdate('Ymd\THis\Z'),
$write('DTSTART', $start),
...($end === null ? [] : [$write('DTEND', $end)]),
'SUMMARY:'.static::escape((string)$event['title']),
...$text('DESCRIPTION', 'description'),
...$text('LOCATION', 'location'),
...(isset($event['url']) ? ['URL:'.static::single((string)$event['url'])] : []),
'END:VEVENT',
]static
ICS :: escape (string $text):string
line 39
strtr(preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/', void, $text), [bs => bs.bs, semi => bs.semi, comma => bs.comma, nl => '\n', lf => '\n', "\r" => '\n'])static
ICS :: single (string $text):string
line 42
A value that takes no escaping, such as a url: without control characters it stays one property.
preg_replace('/[\x00-\x1F\x7F]/', void, $text)static
ICS :: fold (string $line):string
line 45
A line longer than 75 bytes goes on after a line break and a space, between characters rather than inside one.
$out = void
while (strlen($line) > 75){
$cut = 75
while ($cut > 0 && (ord($line[$cut]) & 0xC0) === 0x80) $cut--
// Bytes that are no text at all have no character to keep whole.
$cut || $cut = 75
$out .= substr($line, 0, $cut).nl.space
$line = substr($line, $cut)
}
return $out.$lineobject
%img
/phlo/resources/files/img.phlo
static
img :: detect ($data):?string
line 8
Detecteert het afbeeldingsformaat van gegeven binaire gegevens door de header te onderzoeken en retourneert het bijbehorende formaat als een string.
$header = substr($data, 0, 12)
if (substr($header, 0, 3) === "\xFF\xD8\xFF") return 'jpg'
if (substr($header, 0, 8) === "\x89PNG\x0D\x0A\x1A\x0A") return 'png'
if (substr($header, 0, 6) === 'GIF87a' || substr($header, 0, 6) === 'GIF89a') return 'gif'
if (substr($header, 0, 4) === 'RIFF' && substr($header, 8, 4) === 'WEBP') return 'webp'
if (substr($header, 0, 2) === "BM") return 'bmp'
if (substr($header, 0, 4) === "\x49\x49\x2A\x00" || substr($header, 0, 4) === "\x4D\x4D\x00\x2A") return 'tiff'static
img :: __handle
line 18
Dit haalt de afbeeldingsbron op van het opgegeven bestandspad.
"img/$file"method
%img -> __construct (public string $file)
line 19
Initialiseert een img-object met een openbare stringeigenschap $file die het bestandspad van de afbeelding vertegenwoordigt.
prop
%img -> src:GdImage
line 21
static::upright(imagecreatefromstring(file_get_contents($this->file)), $this->file)static
img :: upright (GdImage $image, string $file):GdImage
line 26
A camera stores a photo as it was taken and says in EXIF how to turn it, which GD ignores, so a
if (!function_exists('exif_read_data') || static::detect((string)file_get_contents($file, false, null, 0, 12)) !== 'jpg') return $image
$orientation = (int)(@exif_read_data($file)['Orientation'] ?? 1)
($angle = [3 => 180, 4 => 180, 5 => 270, 6 => 270, 7 => 90, 8 => 90][$orientation] ?? 0) && $image = imagerotate($image, $angle, 0)
in_array($orientation, [2, 4, 5, 7], true) && imageflip($image, IMG_FLIP_HORIZONTAL)
return $imageprop
%img -> width:int
line 33
Haal de breedte op van een afbeeldingsbron die is opgegeven door de `src`-eigenschap.
imagesx($this->src)prop
%img -> height:int
line 34
Geeft de hoogte van de afbeelding die is opgegeven door de `src`-eigenschap.
imagesy($this->src)method
%img -> scale ($width = null, $height = null, $crop = false):static
line 36
Schaalt de afbeelding naar de opgegeven breedte en hoogte, met de mogelijkheid om deze te croppen op basis van de opgegeven parameters.
if (!$width && !$height) return $this
$srcW = $this->width
$srcH = $this->height
$doCrop = ($crop && $width && $height)
if ($width && $height) $scale = $doCrop ? max($width / $srcW, $height / $srcH) : min($width / $srcW, $height / $srcH)
elseif ($width) $scale = $width / $srcW
else $scale = $height / $srcH
if ($scale >= 1) return $this
$scaledW = (int)round($srcW * $scale)
$scaledH = (int)round($srcH * $scale)
$destW = ($width && $height && $doCrop) ? (int)$width : $scaledW
$destH = ($width && $height && $doCrop) ? (int)$height : $scaledH
$offsetX = 0
$offsetY = 0
if ($width && $height && $doCrop){
$offsetX = (int)-round(($scaledW - $destW) / 2)
$offsetY = (int)-round(($scaledH - $destH) / 2)
if ($crop === 'top') $offsetY = 0
elseif ($crop === 'bottom') $offsetY = (int)-($scaledH - $destH)
}
$destImg = imagecreatetruecolor($destW, $destH)
imagealphablending($destImg, false)
imagesavealpha($destImg, true)
imagecopyresampled($destImg, $this->src, $offsetX, $offsetY, 0, 0, $scaledW, $scaledH, $srcW, $srcH)
$this->src = $destImg
$this->width = $destW
$this->height = $destH
return $thismethod
%img -> ext ($file = null):string
line 67
Geeft de bestandsextensie van het opgegeven bestand in kleine letters terug. Als er geen bestand is opgegeven, wordt het standaardbestand van de instantie gebruikt.
strtolower(pathinfo($file ?? $this->file, PATHINFO_EXTENSION))method
%img -> source ($format = null):string
line 69
Haal de bron van een afbeelding op in het opgegeven formaat, of het standaardformaat als er geen is opgegeven, door de uitvoer van de write-methode vast te leggen.
ob_start()
$this->write($format)
return ob_get_clean()method
%img -> save ($file = null):bool
line 75
Slaat de afbeelding op de opgegeven bestandslocatie op als deze is opgegeven; anders schrijft het de afbeelding naar een standaardlocatie.
$file && $this->file = $file
return $this->write(null, $this->file)method
%img -> write ($format = null, $file = null)
line 80
Schrijft de afbeelding naar een bestand in het opgegeven formaat, met JPEG als standaard als er geen formaat is opgegeven. Ondersteunde formaten zijn PNG, GIF, WebP en JPEG.
$format ??= $this->ext()
if ($format === 'png') return imagepng($this->src, $file, 8)
if ($format === 'gif') return imagegif($this->src, $file)
if ($format === 'webp'){
imageistruecolor($this->src) || imagepalettetotruecolor($this->src)
return imagewebp($this->src, $file)
}
return imagejpeg($this->src, $file, 85)object
%INI
/phlo/resources/files/INI.phlo
prop
%INI -> objFile:string
line 8
INI->$objFile wordt gebruikt om een INI-bestandobject te maken of te openen voor het lezen of schrijven van configuratie-instellingen.
static
INI :: __handle
line 10
INI::$__handle haalt de handle op voor het opgegeven INI-bestand, met de optie om het te parseren op basis van de opgegeven parameters.
"INI/$path$filename".(!$parse ? '/0' : void)method
%INI -> __construct (string $filename, ?string $path = null, bool $parse = true)
line 11
Initialiseert een INI-object met een opgegeven bestandsnaam en optioneel pad, en leest het bestand als het toegankelijk is.
$path ??= data
$this->objFile = $path.strtr($filename, [slash => dot]).'.ini'
if (is_readable($this->objFile)) $this->objRead($parse)method
%INI -> objRead ($parse = true)
line 17
Leest een INI-bestand en converteert het naar een obj, waarbij de waarden optioneel in hun respectieve types worden geparsed.
last($this->objData = parse_ini_file($this->objFile, true, $parse ? INI_SCANNER_TYPED : INI_SCANNER_RAW), $this->objChanged = false, $this)method
%INI -> objWrite:int|false
line 18
Schrijft de huidige objectgegevens naar een INI-bestandsformaat, waarbij ervoor wordt gezorgd dat speciale tekens correct worden ontsnapt en het bestand tijdens de schrijfoperatie wordt vergrendeld.
file_put_contents($this->objFile, loop($this->objData, fn($value, $key) => $key.' = '.dq.strtr($value, [dq => bs.dq, lf => '\n']).dq, lf).lf, LOCK_EX)method
%INI -> __destruct
line 20
De INI->__destruct-methode controleert of het object is gewijzigd en roept de objWrite-methode aan indien nodig om opruiming te verzorgen voordat het object wordt vernietigd.
$this->objChanged && $this->objWrite()object
%JSON
/phlo/resources/files/JSON.phlo
static
JSON :: __handle
line 9
Deze functie bouwt een JSON-bestandspad op basis van de opgegeven bestandsnaam en een associatieve boolean-vlag, die het formaat van het pad bepaalt.
"JSON/$path$filename".(is_bool($assoc) ? slash.(int)$assoc : void)method
%JSON -> __construct (string $filename, ?string $path = null, $assoc = null)
line 10
Construeert een JSON-object vanuit een opgegeven bestandsnaam en optioneel pad, waarbij het volledige bestandspad wordt aangemaakt en de JSON-gegevens worden gelezen als het bestand toegankelijk is.
$path ??= data
$this->objFile = $path.strtr($filename, [slash => dot]).'.json'
if (is_readable($this->objFile)) $this->objRead($assoc)readonly
%JSON -> objFile:string
line 16
Converteert een JSON-string naar een Phlo obj voor verdere manipulatie of verwerking.
method
%JSON -> objTouch:bool
line 18
Stelt de objChanged-eigenschap in op true, wat aangeeft dat het object is gewijzigd.
$this->objChanged = truemethod
%JSON -> objRead ($assoc = null)
line 19
Leest een JSON-bestand en converteert het naar een object of een associatieve array op basis van de opgegeven parameter.
last($data = json_read($this->objFile, $assoc), $this->objData = $assoc || is_array($data) ? $data : get_object_vars($data), $this->objChanged = false, $this)method
%JSON -> objWrite ($data, $flags = null)
line 20
Schrijft JSON-gegevens naar een objectbestand, eventueel met opgegeven vlaggen om het schrijfgedrag aan te passen.
first($written = json_write($this->objFile, $data, $flags), $written && $this->objChanged = false)method
%JSON -> __destruct
line 22
Deze methode wordt aangeroepen wanneer een object wordt vernietigd, en zorgt ervoor dat eventuele wijzigingen aan de gegevens van het object worden geschreven voordat het uit het geheugen wordt verwijderd.
$this->objChanged && $this->objWrite($this->objData)object%PDF
/phlo/resources/files/PDF.phlo
static
PDF :: toText (string $file):string
line 8
$process = proc_open('pdftotext '.escapeshellarg($file).' -', [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']], $pipes)
if (!is_resource($process)) error('PDFToText Error: could not start pdftotext')
fclose($pipes[0])
$text = stream_get_contents($pipes[1])
fclose($pipes[1])
$error = stream_get_contents($pipes[2])
fclose($pipes[2])
($code = proc_close($process)) && error("PDFToText Error: pdftotext command failed with code $code. Error: $error")
return rtrim($text, "\f")prop
%PDF -> title:?string
line 20
Genereert een PDF-document met de opgegeven titel.
nullprop
%PDF -> author:?string
line 21
Haalt de auteur van het PDF-document op.
nullprop
%PDF -> subject:?string
line 22
Genereert een PDF-document op basis van het opgegeven onderwerp.
nullprop
%PDF -> keywords:?string
line 23
Genereert een lijst van trefwoorden die zijn geëxtraheerd uit een PDF-document.
nullprop
%PDF -> creator:string
line 24
De PDF->$creator eigenschap haalt de informatie over de maker van het PDF-document op.
'Phlo '.phlo.' (https://phlo.tech/)'prop
%PDF -> filename:string
line 26
Dit item specificeert de bestandsnaam 'Download.pdf' voor een PDF-resource.
'Download.pdf'prop
%PDF -> mode:string
line 27
Stelt de modus in voor PDF-verwerking, waarbij 'D' een specifieke werkwijze aangeeft.
'D'method
%PDF -> fromHTML ($HTML):string
line 29
$mpdf = new \Mpdf\Mpdf
$this->title && $mpdf->SetTitle($this->title)
$this->author && $mpdf->SetAuthor($this->author)
$this->subject && $mpdf->SetSubject($this->subject)
$this->keywords && $mpdf->SetKeywords($this->keywords)
$this->creator && $mpdf->SetCreator($this->creator)
$mpdf->WriteHTML($HTML)
return (string)$mpdf->Output($this->filename, $this->mode)object
%UBL
/phlo/resources/files/UBL.phlo
static
UBL :: invoice (array $data):string
line 8
Genereert een UBL-factuur XML-structuur op basis van de verstrekte factuurgegevens, inclusief informatie over leverancier en klant, lijnitems, belastingberekeningen en totaalbedragen.
$currency = strtoupper((string)($data['currency'] ?? 'EUR'))
$issue = (string)($data['issue_date'] ?? void)
$due = (string)($data['due_date'] ?? void) ?: $issue
$lines = []
$linesSum = 0
$taxSubtotals = []
foreach ((array)($data['lines'] ?? []) AS $i => $line){
$qty = (float)($line['quantity'] ?? 0)
$net = round($qty * (float)($line['unit_price'] ?? 0), 2)
$rate = (float)($line['tax_rate'] ?? 0)
$lines[] = static::xmlLine($i + 1, $line, $qty, $net, $rate, $currency)
$linesSum += $net
$key = number_format($rate, 2, dot, void)
$taxSubtotals[$key] = ($taxSubtotals[$key] ?? 0) + $net
}
$tax = (float)($data['tax_amount'] ?? 0)
$total = (float)($data['total_amount'] ?? 0)
$taxXml = void
foreach ($taxSubtotals AS $rate => $taxable){
$amount = round($taxable * (float)$rate / 100, 2)
$category = (float)$rate === 0.0 ? 'Z' : 'S'
$taxXml .= implode(void, [
'<cac:TaxSubtotal>',
'<cbc:TaxableAmount currencyID="'.$currency.'">'.static::n($taxable).'</cbc:TaxableAmount>',
'<cbc:TaxAmount currencyID="'.$currency.'">'.static::n($amount).'</cbc:TaxAmount>',
'<cac:TaxCategory><cbc:ID>'.$category.'</cbc:ID><cbc:Percent>'.static::n((float)$rate).'</cbc:Percent>',
'<cac:TaxScheme><cbc:ID>VAT</cbc:ID></cac:TaxScheme></cac:TaxCategory>',
'</cac:TaxSubtotal>',
])
}
$supplier = (array)($data['supplier'] ?? [])
$customer = (array)($data['customer'] ?? [])
return implode(void, [
'<?xml version="1.0" encoding="UTF-8"?>',
'<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">',
'<cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0</cbc:CustomizationID>',
'<cbc:ProfileID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</cbc:ProfileID>',
'<cbc:ID>'.static::esc((string)($data['number'] ?? void)).'</cbc:ID>',
'<cbc:IssueDate>'.static::esc($issue).'</cbc:IssueDate>',
'<cbc:DueDate>'.static::esc($due).'</cbc:DueDate>',
'<cbc:InvoiceTypeCode>'.(!empty($data['credit_note']) ? '381' : '380').'</cbc:InvoiceTypeCode>',
'<cbc:DocumentCurrencyCode>'.$currency.'</cbc:DocumentCurrencyCode>',
static::partyXml('AccountingSupplierParty', (string)($supplier['name'] ?? void), $supplier, (string)($supplier['vat'] ?? void)),
static::partyXml('AccountingCustomerParty', (string)($customer['name'] ?? void), $customer, (string)($customer['vat'] ?? void)),
'<cac:TaxTotal><cbc:TaxAmount currencyID="'.$currency.'">'.static::n($tax).'</cbc:TaxAmount>'.$taxXml.'</cac:TaxTotal>',
'<cac:LegalMonetaryTotal>',
'<cbc:LineExtensionAmount currencyID="'.$currency.'">'.static::n($linesSum).'</cbc:LineExtensionAmount>',
'<cbc:TaxExclusiveAmount currencyID="'.$currency.'">'.static::n($linesSum).'</cbc:TaxExclusiveAmount>',
'<cbc:TaxInclusiveAmount currencyID="'.$currency.'">'.static::n($total).'</cbc:TaxInclusiveAmount>',
'<cbc:PayableAmount currencyID="'.$currency.'">'.static::n($total).'</cbc:PayableAmount>',
'</cac:LegalMonetaryTotal>',
implode(void, $lines),
'</Invoice>',
])static
UBL :: xmlLine ($idx, $line, $qty, $net, $rate, $currency = 'EUR'):string
line 65
Genereert een XML-representatie van een factuurregel, inclusief details zoals hoeveelheid, bedrag, artikelbeschrijving, belastingcategorie en prijs.
$category = (float)$rate === 0.0 ? 'Z' : 'S'
return implode(void, [
'<cac:InvoiceLine>',
'<cbc:ID>'.$idx.'</cbc:ID>',
'<cbc:InvoicedQuantity unitCode="EA">'.static::n($qty).'</cbc:InvoicedQuantity>',
'<cbc:LineExtensionAmount currencyID="'.$currency.'">'.static::n($net).'</cbc:LineExtensionAmount>',
'<cac:Item><cbc:Name>'.static::esc((string)($line['description'] ?? void)).'</cbc:Name>',
'<cac:ClassifiedTaxCategory><cbc:ID>'.$category.'</cbc:ID><cbc:Percent>'.static::n((float)$rate).'</cbc:Percent>',
'<cac:TaxScheme><cbc:ID>VAT</cbc:ID></cac:TaxScheme></cac:ClassifiedTaxCategory></cac:Item>',
'<cac:Price><cbc:PriceAmount currencyID="'.$currency.'">'.static::n((float)($line['unit_price'] ?? 0)).'</cbc:PriceAmount></cac:Price>',
'</cac:InvoiceLine>',
])static
UBL :: partyXml ($wrapper, $name, $info, $vatNumber):string
line 80
Genereert een XML-representatie van een partij-element voor UBL, inclusief details zoals naam, adres, stad, postcode, land en belastinginformatie.
$address = (string)($info['address'] ?? void)
$postal = (string)($info['postal_code'] ?? void)
$city = (string)($info['city'] ?? void)
$country = (string)($info['country'] ?? void) ?: 'NL'
$tax = $vatNumber ? '<cac:PartyTaxScheme><cbc:CompanyID>'.static::esc($vatNumber).'</cbc:CompanyID><cac:TaxScheme><cbc:ID>VAT</cbc:ID></cac:TaxScheme></cac:PartyTaxScheme>' : void
return implode(void, [
'<cac:'.$wrapper.'><cac:Party>',
'<cac:PartyName><cbc:Name>'.static::esc($name).'</cbc:Name></cac:PartyName>',
'<cac:PostalAddress>',
'<cbc:StreetName>'.static::esc($address).'</cbc:StreetName>',
'<cbc:CityName>'.static::esc($city).'</cbc:CityName>',
'<cbc:PostalZone>'.static::esc($postal).'</cbc:PostalZone>',
'<cac:Country><cbc:IdentificationCode>'.static::esc(strtoupper($country)).'</cbc:IdentificationCode></cac:Country>',
'</cac:PostalAddress>',
$tax,
'<cac:PartyLegalEntity><cbc:RegistrationName>'.static::esc($name).'</cbc:RegistrationName></cac:PartyLegalEntity>',
'</cac:Party></cac:'.$wrapper.'>',
])static
UBL :: n ($v):string
line 101
Formatteert een getal naar twee decimalen met behulp van het opgegeven decimaalteken en duizendtallen scheidingsteken.
number_format((float)$v, 2, dot, void)static
UBL :: esc ($v):string
line 102
Converteert speciale tekens naar HTML-entiteiten voor XML-uitvoer, en zorgt voor de juiste codering van UTF-8-strings.
htmlspecialchars((string)$v, ENT_XML1 | ENT_QUOTES, 'UTF-8')object
%upload
/phlo/resources/files/upload.phlo
prop
%upload -> dir
line 9
data.'uploads/'prop
%upload -> max
line 10
2147483648prop
%upload -> canUpload
line 12
Whether this request may upload, the app's answer: prop %upload.canUpload => (bool)%account->user
trueprop
%upload -> owner
line 15
An upload belongs to the session that started it; the owner key survives a renewed session id.
%session->upload ??= token(16)method
%upload -> meta (string $id):?array
line 17
if (!preg_match('/^[a-z]{24}$/', $id) || !is_file($file = $this->dir.$id.'.json')) return null
$meta = json_decode((string)file_get_contents($file), true)
return is_array($meta) && hash_equals((string)$meta['owner'], $this->owner) ? $meta : nullmethod
%upload -> offset (string $id):int
line 23
is_file($this->dir.$id) ? filesize($this->dir.$id) : (is_file($part = $this->dir.$id.'.part') ? filesize($part) : 0)route
route async POST upload
line 26
Starts an upload of a name, size and type and answers with its id.
if (!%upload->canUpload) return output(['error' => 'Not allowed'], code: 403)
$size = (int)(%payload->size ?? 0)
if ($size < 1 || $size > %upload->max) return output(['error' => 'File too large'], code: 413)
$upload = %upload
is_dir($upload->dir) || mkdir($upload->dir, 0700, true)
// What nobody finished or took for a day goes, a finished upload as well.
foreach (glob($upload->dir.'*.json') ?: [] AS $meta){
$stale = substr($meta, 0, -5)
if (max(filemtime($meta), (int)@filemtime($stale.'.part')) < time() - 86400) [@unlink($meta), @unlink($stale), @unlink($stale.'.part')]
}
$id = token(24)
json_write($upload->dir.$id.'.json', ['name' => basename((string)%payload->name), 'size' => $size, 'type' => (string)%payload->type, 'owner' => $upload->owner, 'started' => time()])
touch($upload->dir.$id.'.part')
return output(['id' => $id, 'offset' => 0])route
route async GET upload $id
line 44
Where an upload stands, so a client that lost its connection knows where to go on.
if (!%upload->meta($id)) return output(['error' => 'Unknown upload'], code: 404)
return output(['offset' => %upload->offset($id), 'done' => is_file(%upload->dir.$id)])route
route async PUT upload $id
line 51
A part, accepted only at the offset the upload has reached, so no part is written twice or out
$upload = %upload
if (!$upload->canUpload) return output(['error' => 'Not allowed'], code: 403)
if (!$meta = $upload->meta($id)) return output(['error' => 'Unknown upload'], code: 404)
$offset = $upload->offset($id)
if ((int)%req->header('Upload-Offset') !== $offset) return output(['error' => 'Wrong offset', 'offset' => $offset], code: 409)
$body = %req->body
if ($offset + strlen($body) > $meta['size']) return output(['error' => 'More than the file'], code: 413)
file_put_contents($upload->dir.$id.'.part', $body, FILE_APPEND | LOCK_EX)
$offset += strlen($body)
$offset === $meta['size'] && rename($upload->dir.$id.'.part', $upload->dir.$id)
return output(['offset' => $offset, 'done' => $offset === $meta['size']])static
upload :: take (string $id):?file
line 66
The finished upload as a file with the name it was sent with, or null; move it where it belongs.
$upload = %upload
if (!($meta = $upload->meta($id)) || !is_file($upload->dir.$id)) return null
@unlink($upload->dir.$id.'.json')
return %file($upload->dir.$id, name: $meta['name'])view
script
line 73
app.requests.push((xhr, method, path, data) => {
if (!(data instanceof FormData) || ![...data.values()].some(value => value instanceof File && value.size)) return
const html = document.documentElement
xhr.upload.onprogress = e => e.lengthComputable && [html.classList.add('uploading'), html.style.setProperty('--upload', e.loaded / e.total), document.dispatchEvent(new CustomEvent('upload', {detail: {loaded: e.loaded, total: e.total, path}}))]
xhr.upload.onloadend = () => [html.classList.remove('uploading'), html.style.removeProperty('--upload')]
})
const uploadSend = (method, path, body, offset = null, progress = null) => new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest
xhr.open(method, `${location.origin}/${path}`)
xhr.setRequestHeader('X-Requested-With', 'phlo')
offset === null || xhr.setRequestHeader('Upload-Offset', offset)
app.requests.forEach(hook => hook(xhr, method, path, body))
progress && (xhr.upload.onprogress = progress)
xhr.onload = () => xhr.status < 300 ? resolve(JSON.parse(xhr.responseText)) : reject(xhr)
xhr.onerror = () => reject(xhr)
xhr.send(body)
})
app.upload = async (file, onprogress = null) => {
const key = `upload:${file.name}:${file.size}:${file.lastModified}`
const known = localStorage.getItem(key)
let {id, offset} = known ? await uploadSend('GET', `upload/${known}`).then(r => ({id: known, offset: r.offset})).catch(() => ({})) : {}
if (!id){
const start = new FormData
start.append('name', file.name)
start.append('size', file.size)
start.append('type', file.type)
const started = await uploadSend('POST', 'upload', start)
id = started.id
offset = started.offset
}
localStorage.setItem(key, id)
for (let tries = 0; offset < file.size;){
const part = file.slice(offset, offset + 8388608)
try { ({offset} = await uploadSend('PUT', `upload/${id}`, part, offset, e => onprogress?.((offset + e.loaded) / file.size))); tries = 0 }
catch (xhr){
if (++tries > 3) throw xhr
offset = xhr.status === 409 ? JSON.parse(xhr.responseText).offset : await new Promise(r => setTimeout(r, 1000 * tries)).then(() => uploadSend('GET', `upload/${id}`)).then(r => r.offset).catch(() => offset)
}
}
localStorage.removeItem(key)
return id
}
on('change', 'input[type=file][data-upload]', input => {
const form = input.form
const name = input.dataset.name ??= input.name
const hidden = form.querySelector(`input[type=hidden][name="${name}"]`) ?? form.appendChild(Object.assign(document.createElement('input'), {type: 'hidden', name}))
hidden.value = ''
input.removeAttribute('name')
input.files[0] && [form.classList.add('uploading'), app.upload(input.files[0], share => [input.style.setProperty('--upload', share), input.dispatchEvent(new CustomEvent('upload', {bubbles: true, detail: {share}}))]).then(id => hidden.value = id).finally(() => form.classList.remove('uploading'))]
})object
%XLSX
/phlo/resources/files/XLSX.phlo
method
%XLSX -> __construct (string $file)
line 14
Reads the sheets straight out of the zip with regular expressions instead of an XML parser.
$sheets = []
$shared = []
$sheetNames = []
$zip = new ZipArchive()
if ($zip->open($file) !== true) error('XLSX: cannot open '.basename($file))
for ($i = 0; $i < $zip->numFiles; $i++){
$name = $zip->getNameIndex($i)
if ($name === false) continue
if (dirname($name) === 'xl/worksheets') $sheets[filter_var($name, FILTER_SANITIZE_NUMBER_INT)] = $zip->getFromIndex($i)
elseif ($name === 'xl/sharedStrings.xml'){
$xml = $zip->getFromIndex($i)
if (!preg_match_all('/<si(?:\s[^>]*)?>(.*?)<\/si>/s', $xml, $m)) error('XLSX: unreadable shared strings in '.basename($file))
$shared = array_map(fn($si) => static::text($si), $m[1])
}
elseif ($name === 'xl/workbook.xml'){
$xml = $zip->getFromIndex($i)
if (!preg_match_all('/<sheet[^>]*name="([^"]+)"[^>]*sheetId="([0-9]+)"/', $xml, $m)) error('XLSX: unreadable workbook in '.basename($file))
$sheetNames = $m[1]
}
}
$zip->close()
$toIndex = fn($letters) => array_reduce(str_split(strtoupper($letters)), fn($n, $c) => $n * 26 + ord($c) - 64, 0) - 1
$isShared = fn($attrs) => preg_match('/(?:^|\s)t="s"/', $attrs) === 1
foreach ($sheets AS $sheetID => $sheet){
$name = $sheetNames[$sheetID - 1] ?? 'Sheet '.$sheetID
if (!preg_match('/<row[^>]*>(.+)<\/row>/s', $sheet, $m)) error('XLSX: unreadable sheet in '.basename($file))
$rowsXml = preg_split('/<\/row><row[^>]*>/', $m[1]) ?: []
$headerMap = []
$isHeader = true
foreach ($rowsXml AS $rowXml){
$rowXml = preg_replace('/<c([^>]*)\/>/', '<c$1></c>', $rowXml)
if (!preg_match_all('/<c r="([A-Z]+)[0-9]+"([^>]*)>(?:<f\b[^>]*\/?>)?(?:(?:<v>([^<]*)<\/v>)|(?:<is>(.*?)<\/is>))?<\/c>/s', $rowXml, $mm)) error('XLSX: unreadable row in '.basename($file))
if ($isHeader){
foreach (array_keys($mm[0]) AS $i){
$col = $toIndex($mm[1][$i])
$attrs = $mm[2][$i]
$valV = $mm[3][$i] ?? null
$valIS = $mm[4][$i] ?? null
$val = $valV !== null && $valV !== void ? $valV : ($valIS !== null && $valIS !== void ? static::text($valIS) : null)
$txt = $isShared($attrs) ? ($shared[$val] ?? null) : $val
$headerMap[$col] = $txt !== null && $txt !== void ? $txt : 'col'.$col
}
$isHeader = false
}
else {
$rowArr = []
foreach (array_keys($mm[0]) AS $i){
$col = $toIndex($mm[1][$i])
$attrs = $mm[2][$i]
$valV = $mm[3][$i] ?? null
$valIS = $mm[4][$i] ?? null
$val = $valV !== null && $valV !== void ? $valV : ($valIS !== null && $valIS !== void ? static::text($valIS) : null)
$key = $headerMap[$col] ?? 'col'.$col
$rowArr[$key] = $isShared($attrs) ? ($shared[$val] ?? null) : $val
}
$this->objData[$name][] = $rowArr
}
}
}static
XLSX :: text (string $xml):string
line 77
The text of a shared or inline string: every run joined, the phonetic guide left out.
preg_match_all('/<t(?:\s[^>]*)?(?<!\/)>(.*?)<\/t>/s', preg_replace('/<rPh\b.*?<\/rPh>/s', void, $xml), $m)
return html_entity_decode(implode($m[1]), ENT_QUOTES | ENT_XML1, 'UTF-8')static
XLSX :: write (string $file, array $sheets):void
line 84
A workbook of sheets, name => rows. Text is written inline rather than in a shared table, which
$zip = new ZipArchive
$zip->open($file, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true || error('XLSX: cannot write '.basename($file))
$x = fn($v) => htmlspecialchars((string)$v, ENT_XML1 | ENT_QUOTES, 'UTF-8');
$cell = fn($v, $ref) => is_int($v) || is_float($v) ? "<c r=\"$ref\"><v>$v</v></c>" : '<c r="'.$ref.'" t="inlineStr"><is><t xml:space="preserve">'.$x($v).'</t></is></c>';
$line = fn(array $values, int $r) => '<row r="'.$r.'">'.implode(loop(array_values($values), fn($v, $c) => $cell($v, static::column($c).$r))).'</row>';
$names = array_values(array_map(fn($n) => mb_substr(preg_replace('#[\\\\/?*\\[\\]:]#', space, (string)$n), 0, 31), array_keys($sheets)))
$zip->addFromString('[Content_Types].xml', '<?xml version="1.0" encoding="UTF-8"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>'.implode(loop($names, fn($n, $i) => '<Override PartName="/xl/worksheets/sheet'.($i + 1).'.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>')).'</Types>')
$zip->addFromString('_rels/.rels', '<?xml version="1.0" encoding="UTF-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>')
$zip->addFromString('xl/workbook.xml', '<?xml version="1.0" encoding="UTF-8"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets>'.implode(loop($names, fn($n, $i) => '<sheet name="'.$x($n).'" sheetId="'.($i + 1).'" r:id="rId'.($i + 1).'"/>')).'</sheets></workbook>')
$zip->addFromString('xl/_rels/workbook.xml.rels', '<?xml version="1.0" encoding="UTF-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'.implode(loop($names, fn($n, $i) => '<Relationship Id="rId'.($i + 1).'" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet'.($i + 1).'.xml"/>')).'</Relationships>')
foreach (array_values($sheets) AS $i => $rows){
$xml = void
$r = 0
foreach ($rows AS $n => $row){
$row = (array)($row instanceof obj ? $row->objData : $row)
$n === array_key_first($rows) && !array_is_list($row) && $xml .= $line(array_map('strval', array_keys($row)), ++$r)
$xml .= $line($row, ++$r)
}
$zip->addFromString('xl/worksheets/sheet'.($i + 1).'.xml', '<?xml version="1.0" encoding="UTF-8"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>'.$xml.'</sheetData></worksheet>')
}
$zip->close()static
XLSX :: column (int $i):string
line 109
A column's letters: 0 is A, 25 is Z, 26 is AA.
($i >= 26 ? static::column(intdiv($i, 26) - 1) : void).chr(65 + $i % 26)static
XLSX :: download (array $sheets, string $filename):void
line 111
$file = tempnam(sys_get_temp_dir(), 'xlsx')
static::write($file, $sheets)
output(file: $file, filename: $filename, attachment: true, type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
@unlink($file)Laatst bijgewerkt op 04-11-2026