Download the PHP package jacksleight/laravel-raster without Composer

On this page you can find all versions of the php package jacksleight/laravel-raster. 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 laravel-raster

Raster

Rasterise views and components to images by simply adding a directive and fetching the URL. Automatic routing, scaling, caching, protection and preview mode. Zero configuration (unless you need it).

Installation

Run the following command from your project root:

This package uses Puppeteer via spatie/browsershot under the hood, you will also need follow the necessary Puppeteer installation steps for your system. I can't help with Puppeteer issues or rendering inconsistencies, sorry.

If you need to customise the config you can publish it with:

Usage

Layout Setup

The views will be rendered inside a layout view where you can load any required CSS and other assets. By default this is a component called layouts.raster, but you can change it in the config file.

Automatic Mode

To make a view rasterizeable simply implement the @raster directive and then generate a URL to your image using the raster() helper. The data closure receives any parameters passed in the URL and should return an array of data to pass to the view.

You can set options with the directive or through the URL by chaining methods on to the helper. The options passed in the URL take priority over options set in the directive.

When the view is rendered during normal non-raster requests the directive does nothing.

[!IMPORTANT] Views rasterised using automatic mode must implement the raster directive.

Manual Mode

If you would like more control over the routing and how the requests are handled you can define your own routes that return raster responses and then generate a URL to your image using the usual route() helper.

[!IMPORTANT] Views rasterised using manual mode must not implement the raster directive.

Customising Rasterised Views

If you would like to make changes to the view based on whether or not it's being rasterised you can check for the $raster variable:

Options

The following options can be set with the directive or by chaining methods on to the object:

With PDF output a height is required, it will only contain one page, and dimensions are still pixels not mm/inches. If you're looking to generate actual documents from views I highly recommend checking out spatie/laravel-pdf.

Caching

The following caching options can be set with the directive or by chaining methods on to the object. The cacheId cannot be passed as a URL parameter. You can globally disable caching by setting the RASTER_CACHE_ENABLED env var to false. By default the cache will be stored locally in storage/app/raster, you can change this by setting the RASTER_CACHE_DISK and RASTER_CACHE_PATH env vars.

File paths will use this pattern: [cache_path]/[view_name]/[cache_id]/[params_hash].[extension].

Viewport Basis

When the basis option is set the image will be generated as if the viewport was that width, but the final image will match the desired width. Here's an example of how that affects output:

Viewport Basis

Preview Mode

In preview mode the HTML will be returned from the response but with all the appropriate scaling applied. This gives you a 1:1 preview without the latency that comes from generating the actual image.

Security & URL Signing

Only views that implement the @raster directive can be rasterised in automatic mode, an error will be thrown before execution if they don't. It's also recommended to enable URL signing on production to ensure they can't be tampered with. You can do this by setting the RASTER_SIGN_URLS env var to true.

Customising Browsershot

If you need to customise the Browsershot instance you can pass a closure to Raster::browsershot() in a service provider:

Sponsoring

This package is completely free to use. However fixing bugs, adding features and helping users takes time and effort. If you find this useful and would like to support its development any contribution would be greatly appreciated. Thanks! 🙂


All versions of laravel-raster with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1|^8.2|^8.3
laravel/framework Version ^10.0|^11.0
spatie/browsershot Version ^4.3
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 jacksleight/laravel-raster contains the following files

Loading the files please wait ....