PHPackages                             loadsys/cakephp-svg-icon - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. loadsys/cakephp-svg-icon

ActiveCakephp-plugin[Utility &amp; Helpers](/categories/utility)

loadsys/cakephp-svg-icon
========================

SvgIcon plugin for CakePHP

v2.0.0(2y ago)1600MITPHPPHP &gt;=8.2

Since Feb 21Pushed 2y ago3 watchersCompare

[ Source](https://github.com/loadsys/cakephp-svg-icon)[ Packagist](https://packagist.org/packages/loadsys/cakephp-svg-icon)[ RSS](/packages/loadsys-cakephp-svg-icon/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

SvgIcon plugin for CakePHP 5.x
==============================

[](#svgicon-plugin-for-cakephp-5x)

[![Build Status](https://github.com/loadsys/cakephp-svg-icon/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/loadsys/cakephp-svg-icon/actions/workflows/ci.yml/badge.svg?branch=main)

This plugin offers an easy way to display SVG icons, with options to customize and/or cache them. It's packaged as a trait that can be used anywhere in your app, with a helper (using the trait) for convenience and caching.

Installation
------------

[](#installation)

You can install this plugin into your CakePHP application using [composer](https://getcomposer.org).

The recommended way to install composer packages is:

```
composer require loadsys/cakephp-svg-icon

```

Versions
--------

[](#versions)

- Tags `1.x` are for CakePHP v4.x.
- Tags `2.x` are for CakePHP v5.x.

Configuration
-------------

[](#configuration)

Icons should be added to `config/app_svg_icon.php` - see the example included in `config` directory for the expected format. Any SVG icon should work, such as [heroicons](https://heroicons.com) or [Bootstrap Icons](https://icons.getbootstrap.com).

Icons will be cached using the `default` cache config. This can be changed by supplying a different cache config when loading the helper:

```
/*
 * src/View/AppView.php
 */
public function initialize(): void
{
    $this->loadHelper('SvgIcon.SvgIcon', [
        'cacheConfig' => 'svg_icon',
    ]);
}
```

This example would use the `svg_icon` cache config, which can be set in `config/app/php`:

```
/*
 * Optional configuration settings for the SvgIcon plugin cache
 */
'svg_icon' => [
    'className' => FileEngine::class,
    'prefix' => 'svg_icon_',
    'path' => CACHE . 'views' . DS,
    'duration' => '+1 years',
    'url' => env('CACHE_DEFAULT_URL', null),
]
```

Usage
-----

[](#usage)

Configured icons can be displayed by name - here's an example based on the names used in the sample `config/app_svg_icon.php`.

```
