Download the PHP package saade/facehash without Composer

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

Facehash for Laravel

Deterministic avatar faces from any string. A PHP/Laravel port of the facehash JavaScript library.

Generates unique, consistent SVG avatars based on a name, email, or any string input. No GD, Imagick, or external services required — pure SVG output.

Requirements

Installation

Quick Start

API

All methods return a new instance (immutable), so you can chain freely without affecting the original.

name(string $name)

Required. The input string to generate the avatar from. The same string always produces the same face.

size(int $pixels)

Avatar dimensions in pixels. Default: 40.

variant(string $variant)

Background style. Accepts 'gradient' or 'solid'. Default: 'gradient'.

format(string $format)

Avatar shape. Accepts 'square', 'squircle', or 'circle'. Default: 'circle'.

blink(bool $enable = true)

Adds a CSS blink animation to the eyes inside the SVG. Default: false.

initial(bool $show = true)

Show the first letter of the name below the eyes. Default: true.

colors(array $colors)

Override the color palette. Each avatar picks a color deterministically from this array.

Output Methods

Method Returns
toSvg() Raw SVG string
toBase64() Base64-encoded SVG string
toUri() Data URI (data:image/svg+xml;base64,...)

HTTP Route

The package includes an optional GET route that serves avatars as image/svg+xml responses with long-lived cache headers. The route is disabled by default — enable it in your config:

Query Parameters

Parameter Type Default Description
name string required Input string
size int 40 Size in pixels (16–1024)
variant string gradient gradient or solid
format string circle square, squircle, or circle
initial bool true Show initial letter
blink bool false Enable blink animation
colors[] string[] Custom hex color palette

Examples

Blade Usage

Configuration

Publish the config file:

This creates config/facehash.php:

Config Options

defaults — Default values for the builder. Any method call overrides these per-instance.

colors — The color palette. Each avatar deterministically picks one color from this array. The default palette uses Tailwind CSS 500-weight colors.

route.enabled — Set to true to register the HTTP endpoint. Disabled by default.

route.prefix — URL path for the HTTP endpoint.

route.middleware — Middleware applied to the route.

route.cache_control — Cache-Control header value. The default serves immutable responses cached for 1 year — safe because the same input always produces the same output.

How It Works

  1. The input string is hashed to a deterministic 32-bit integer
  2. The hash selects a face type (round, cross, line, curved), a color, and a rotation (3D look direction)
  3. The SVG renderer composites: clip path (circle, square, or squircle), background color, gradient overlay, eye shapes, position offset, and initial letter
  4. The same string always produces the exact same SVG — across requests, servers, and deployments

The hash function is a direct port of the JavaScript original, producing identical output for any given input.

Face Types

Type Description
Round Circular dot eyes
Cross Plus-sign shaped eyes
Line Horizontal bar eyes
Curved Sleepy/arc eyes

Unique Combinations

4 face types × 5 colors × 9 rotation positions = 180 visually distinct avatars from the default palette. Custom color palettes increase this further.

Demo

A standalone demo page is included for testing without Laravel:

Open http://localhost:8080 to see the avatar gallery, variant comparisons, and an interactive playground.

Credits

This package is a PHP/Laravel port of facehash by Cossistant. The original JavaScript library provides the face SVG data, hash algorithm, and rendering logic that this package faithfully reproduces.

License

MIT


All versions of facehash with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^11.0|^12.0|^13.0
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 saade/facehash contains the following files

Loading the files please wait ...