natewiebe13 / php-lucide
PHP library for Lucide icons
Requires
- php: >=7.4
Requires (Dev)
- ext-dom: *
- ext-json: *
- ext-libxml: *
- ext-simplexml: *
- phpunit/phpunit: ^9.5
- v1.0.x-dev
- v1.0.91
- v1.0.90
- v1.0.89
- v1.0.88
- v1.0.87
- v1.0.86
- v1.0.85
- v1.0.84
- v1.0.83
- v1.0.82
- v1.0.81
- v1.0.80
- v1.0.79
- v1.0.78
- v1.0.77
- v1.0.76
- v1.0.75
- v1.0.74
- v1.0.73
- v1.0.72
- v1.0.71
- v1.0.70
- v1.0.69
- v1.0.68
- v1.0.67
- v1.0.66
- v1.0.65
- v1.0.64
- v1.0.63
- v1.0.62
- v1.0.61
- v1.0.60
- v1.0.59
- v1.0.58
- v1.0.57
- v1.0.56
- v1.0.55
- v1.0.54
- v1.0.53
- v1.0.52
- v1.0.51
- v1.0.50
- v1.0.49
- v1.0.48
- v1.0.47
- v1.0.46
- v1.0.45
- v1.0.44
- v1.0.43
- v1.0.42
- v1.0.41
- v1.0.40
- v1.0.39
- v1.0.38
- v1.0.37
- v1.0.36
- v1.0.35
- v1.0.34
- v1.0.33
- v1.0.32
- v1.0.31
- v1.0.30
- v1.0.29
- v1.0.28
- v1.0.27
- v1.0.26
- v1.0.25
- v1.0.24
- v1.0.23
- v1.0.22
- v1.0.21
- v1.0.20
- v1.0.19
- v1.0.18
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-automated/lucide-update
This package is auto-updated.
Last update: 2025-04-01 12:42:46 UTC
README
PHP Library for Lucide.
For more information on Lucide itself, please refer to their README.
Installation
Install php-lucide
using Composer.
composer require natewiebe13/php-lucide
Versioning
This library uses Semantic Versioning as a versioning strategy. This covers the public API, but does not guarantee backwards compatibility with breaking changes made by Lucide (ex: icon name changes). Any large backwards compatibility breaks made by Lucide may result in a new major version of this library, but will be determined on a case by case basis. In the event that an icon naming change is made, the Aliases feature can be used to assist migrating to the new icon name.
Usage
Icons
Icons
are retrieved from an IconManager
.
<?php $icons = new \Lucide\IconManager(); ?> <!-- Display the 'anchor' icon --> <?php echo $icons->getIcon('anchor'); ?> <!-- Get creative! --> <button class="icon-button"> Learn More <?= $icons->getIcon('arrow-right'); ?> </button>
Lucide\IconManager::getIcon()
returns an Icon
object. To render the icon html itself, either cast the Icon
as a string or call its render()
function.
$icons->getIcon('anchor'); // Returns an Icon object $html = $icons->getIcon('anchor')->render(); // Returns the icon's html echo $icons->getIcon('anchor'); // Outputs the icon's html, since it is cast as a string
Attributes
Attributes can be modified on both the IconManager
and on Icon
objects. Attributes can be modified directly using the setAttribute(s)
functions or by using the helper functions.
Attribute changes on the IconManager
will affect all Icon
objects created by the IconManager
. Changes on Icon
objects will only affect the individual icons.
// Use on the IconManager instance to set default attributes for all icons $icons->setAttributes(['stroke' => '#fff', 'stroke-width' => 2]); $icons->setAttribute('stroke', '#fff'); $icons->setSize(24); $icons->setColor('#fff'); $icons->setWeight(2); $icons->addCssClass('foo'); // Or use on a single icon to only affect that one echo $icons->getIcon('alert-triangle')->setColor('red')->setAttribute('data-alert', 'true');
Accessibility
When getting an Icon
, alt text can be passed as an argument or can be set on the Icon
at a later time.
$icons->getIcon('anchor', [], 'Icon of an anchor'); $icon->setAltText('Icon of an anchor');
Aliases
Aliases can be set to make larger changes across a theme easier, such as replacing the actual icon used for a specific use case. For example, what if for the close button icon, you wanted to switch
from using the x
icon to x-circle
. Instead of having the icon name hardcoded, you could use an alias for the use case and update the value in one place. Aliases are set on the IconManager
.
$icons->addAlias('close-button', 'x');
Contributing
Feel free to open up issues and PRs for suggestions.
License
Licensed under the MIT License.
The icons in this code are from Lucide. Which is licensed under the ISC License.