Skip to content

Commit

Permalink
Merge pull request #14 from rico-vz/docs/updateReadme
Browse files Browse the repository at this point in the history
Update README with toString() + fix typo
  • Loading branch information
simonhamp authored Jan 8, 2024
2 parents 43ad6f0 + 9e1a3c1 commit b9f660b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
/node_modules
/phpunit.xml
/.phpunit.cache

.idea/
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ The default theme is `Light`.
You can set the theme on your image at any point before it's rendered:

```php
use SimonHamp\TheOg\Themes\Themes;

$image = new Image;
$image->theme(Theme::Dark);
$image->theme(Themes::Dark);
```

#### Creating themes
Expand Down Expand Up @@ -105,6 +107,25 @@ There are currently 2 layouts: `Standard` and `GitHubBasic`. `Standard` is the d

More layouts are coming.

### Storing the image elsewhere

If you prefer to store your image somewhere other than the local filesystem (e.g. storing it on Amazon S3) you can use the `toString()` method.

`toString()` will return the rendered image as a binary string:

```php
$image = (new Image())->toString();

// $service here could be an AWS\S3\S3Client, for example
$service->putObject([
'Key' => 'example-image.png',
'Body' => $image,
'ContentType' => 'image/png',
]);
```

This will send the raw binary data directly to the external service without needing to write the image to a file on the local disk first.

## Testing

The OG uses [snapshot testing](https://github.com/spatie/phpunit-snapshot-assertions). To run the integration tests,
Expand Down

0 comments on commit b9f660b

Please sign in to comment.