Download the PHP package avvertix/html-shot without Composer

On this page you can find all versions of the php package avvertix/html-shot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package html-shot

html-shot

HTML to image rendering for PHP, powered by Rust and Takumi. Generate Open Graph images and more from HTML/CSS without headless browser overhead.

Features

Installation

Requirements

The package needs a compiled native library to render images. Download the one matching your platform and the installed package version with the bundled console command:

This fetches the correct binary from the matching GitHub release, verifies its checksum, and stores it in the package lib/ directory.

After upgrading the package, refresh the native library to match the new version:

[!NOTE] A natives.lock file is added to the root of the project. Commit this file to your repo to ensure that each time you'll get the same native version.

Documentation

Quick start

The fastest way in is the HtmlShot façade. Give it some HTML and a few options, and it hands back the encoded image bytes:

Available options: width, height, format (png | webp | jpeg), quality (1–100 for the lossy formats), stylesheets (extra CSS), fonts, and devicePixelRatio (e.g. 2.0 for Retina output).

[!NOTE] See the examples/ directory for deep dive with fonts, custom styles, images and high resolution.

Reusing a context

The façade loads fonts on every call. When you render repeatedly, build a Context once, load the fonts into it, and drive a Renderer directly so the fonts are parsed a single time:

Deep Dive

How HTML & CSS are handled

html-shot is not a browser, so it treats your markup as a layout description rather than a full DOM. A few particularities are worth knowing before you write templates:

Because layout is driven entirely by CSS, lean on the engine's Flexbox and CSS Grid support (plus tw Tailwind utilities) to position things — the usual OG card patterns of centered flex containers and grid feature lists work as you'd expect.

Development

Build the native library

The Rust library must be compiled for your target platform. A pre-built binary is attached to each GitHub release or you can build your own.

Then copy the compiled library to the lib/ directory at the package root:

Platform Source Destination
Linux target/release/libhtml_shot.so ../lib/libhtml_shot.so
macOS target/release/libhtml_shot.dylib ../lib/libhtml_shot.dylib
Windows target/release/html_shot.dll ../lib/html_shot.dll

The C header is auto-generated by cbindgen and written to include/html_shot.h during the build.

Troubleshooting

Enabling ext-ffi

Check whether FFI is active:

If it is not listed, add the following to your php.ini and restart PHP-FPM / your web server:

What is the natives.lock file?

The install writes a natives.lock file to your project root (next to composer.lock). It holds the resolved version and the download URL and checksum of every platform's binary for that release:

Commit this file: when it is present, vendor/bin/htmlshot install reinstalls exactly the locked version and verifies the download against the locked checksum, giving deterministic installs across machines and CI.

Because the lock captures every platform's asset, a lock generated on one OS (e.g. while developing on Windows) lets a build or deployment on a different OS install the matching binary deterministically and verify it offline.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

License

MIT License - see LICENSE file for details.

Credits

Powered by Takumi


All versions of html-shot with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-ffi Version *
composer-runtime-api Version ^2.0
symfony/console Version ^6.4|^7.0|^8.0|^8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package avvertix/html-shot contains the following files

Loading the files please wait ...