Download the PHP package antonioprimera/laravel-heroicons without Composer

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

Laravel HeroIcons

This is a simple, but opinionated package, useful for easily rendering hero icons.

As simple as this (in your blade file):

This package provides you the option to easily include hero icons in your blade files, but also manipulate the html in the icon svg.

HeroIcons are provided by the makers of tailwindcss, and you can find them here: https://heroicons.com/

Installation

Import the package in your Laravel project via composer:

composer require antonioprimera/laravel-heroicons

Usage

Blade directive

The package sets up a dedicated blade directive @heroIcon('icon-name', 'icon-format'). This creates an icon instance and renders it. The first argument is the name (mandatory) and the second argument is the format, which is optional and must be either 'solid' or 'outline'. If not provided, the default format is 'outline'.

This blade directive is created to use the full power of view caching, so it only accepts static (string) parameters, and no variables or constants.

If you need a more flexible option, you can use the blade directive @dynamicHeroIcon($name, $format, $options). This directive will not cache the svg string, but will re-render the svg every time the view is rendered. With this blade directive, you can use variables and constants.

HeroIcon instance

All usage scenarios rely on an instance of AntonioPrimera\HeroIcons\HeroIcon.

The constructor always requires the icon name, as found on the heroicons website. The name is transformed to kebab-case, so you can use any format you like, as long as the kebab case of the name corresponds to an icon in the icon set.

e.g. The following examples create identical icons:

By default, if no format is specified, icons are created from the 'outline' icon subset. You can use one of the two constants exposed by the HeroIcon class:

The third parameter of the constructor is a bitwise combination of options. At the moment the following options are available:

If SVG_CURRENT_COLOR is set, then the default stroke color of the icon is replaced with 'currentColor', so that the icon's color will be the color set in the parent container.

If SVG_REMOVE_SIZE is set, then the default size of the icons (width and height, in pixels) is removed, so that the icon can be resized using classes. In my opinion (this is purely subjective), the best way to use icons, is to set its width to 100% of the parent container and to resize the parent container.

HeroIcon static constructor

You can use the static method HeroIcon::create(...) with the same signature as the constructor, to create a new HeroIcon instance.

Helper

A heroIcon helper function is also available.

Below you can see the function signature.

The helper function will return the rendered html of the svg icon, optionally applying one or more classes (as a string or array) and a set of attributes.

Htmlable

The HeroIcon class implements the Htmlable interface, so you can just drop a HeroIcon instance inside your blade files, between double curly braces, and it will be rendered into an html svg icon. Here's an example:

Methods

Once created, the icon instance can be configured, adding css classes on the outer svg node, setting the size in pixels on the outer svg node, and setting attributes.

setClass(string | array $classes)

This method allows you to set one or more html classes on the outer svg node. The classes can be provided as a string or as an indexed array.

setAttributes(array $attributes)

This method allows you to set one or more attributes on the outer svg node, provided an associative array of attribute name => value pairs.

setPathAttributes(array $attributes)

This method allows you to set one or more attributes on all path nodes inside the svg. The attributes must be provided as an associative array of attributeName => attributeValue pairs.

getSvgInstance()

The HeroIcon class uses the meyfa/php-svg package under the hood, and this method exposes the SVG\SVG instance used by the HeroIcon instance to manipulate and render the svg.

Future development

The package might use some more advanced features, like:

This package should remain very lightweight and fast. For advanced usage


All versions of laravel-heroicons with dependencies

PHP Build Version
Package Version
Requires meyfa/php-svg Version ^0.11.2
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 antonioprimera/laravel-heroicons contains the following files

Loading the files please wait ....