Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
odan committed Nov 10, 2023
1 parent 8f43355 commit 72628f8
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,9 @@ $workbook->save($file);

**Generating only In-Memory Excel file**

This data is purely an in-memory stream,
and it never spills over to disk,
regardless of the amount of data written to it.
Use `php://memory` (default) when you want to
ensure that the data remains in memory and
don't want PHP to switch to disk storage,
even for large amounts of data.
This data is a pure in-memory stream `php://memory` (default)
that never overflows onto the hard disk,
regardless of the amount of data written.

```php
use Odan\Excel\ZipDeflateStream;
Expand All @@ -87,13 +83,13 @@ $file = new ZipDeflateStream();
$workbook->save($file);
```

**Generating a temporary memory-stream with disk access**
**Generating temporary files**

The `php://temp` stream is designed for temporary data storage in memory.

However, if the amount of data written exceeds a certain threshold
(usually around 2KB or 8KB, depending on PHP versions and configurations),
PHP may automatically switch to using temporary files on disk to store the excess data.
PHP may automatically switch to using temporary files on disk to store the data.
This is done to conserve memory when dealing with large amounts of data.

This kind of stream is suitable for most scenarios where you need temporary
Expand Down Expand Up @@ -144,7 +140,7 @@ $file = new ZipDeflateStream('example.xlsx');
$workbook->save($file);
```

... or via in-memory stream.
... or with stream_get_contents.

```php
use Odan\Excel\ZipDeflateStream;
Expand Down Expand Up @@ -177,7 +173,7 @@ $file = new ZipDeflateStream($filename);
$workbook->save($file);
```

**Reading the stream contents**
**Reading the stream contents as string**

```php
use Odan\Excel\ZipDeflateStream;
Expand All @@ -187,11 +183,8 @@ use Odan\Excel\ZipDeflateStream;
$file = new ZipDeflateStream();
$workbook->save($file);

// Get native stream
$stream = $file->getStream();

// Read contents of stream into a string
$data = stream_get_contents($stream);
$data = stream_get_contents($file->getStream());
```

**Stream directly to the HTTP response**
Expand Down

0 comments on commit 72628f8

Please sign in to comment.