flowframe / php-previewify
The official PHP Previewify client
This package's canonical repository appears to be gone and the package has been frozen as a result.
Fund package maintenance!
larsklopstra
Requires
- php: ^7.4|^8.0
- symfony/http-client: ^6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- pestphp/pest: ^1.20
- spatie/ray: ^1.28
This package is auto-updated.
Last update: 2024-08-09 07:02:14 UTC
README
This is the official Previewify client for PHP.
Support us
Like our work? You can support us by purchasing one of our products.
Installation
You can install the package via composer:
composer require flowframe/php-previewify
Usage
Images
Use the image
method to generate downloadable image URLs, be aware that this might increase the loading time on your page. If you want to use this for on-demand previews continue to Async images.
<?php use Flowframe\Previewify\Previewify; $previewify = new Previewify('<YOUR_SITE_API_KEY>'); $response = $previewify->image( templateId: 1, fields: [ 'previewify:title' => 'Hello from PHP SDK', ], ); // `$response` will return the response object // Be aware that you have to handle any errors or exceptions $url = $response->toArray(throw: false)['url'];
Async images
Async images are perfect if you don't want to download the image or use meta tags. It'll return a signed URL which you can put inside your OG or Twitter image meta tag.
<?php use Flowframe\Previewify\Previewify; $previewify = new Previewify('<YOUR_SITE_API_KEY>'); $url = $previewify->asyncImage( templateId: 1, fields: [ 'previewify:title' => 'Hello from PHP SDK', ], ); // <meta name="twitter:image" content="{{ $url }}" >
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.