yassinedoghri / codeigniter-icons
A CodeIgniter4 library with convenient helper functions to render svg icons using yassinedoghri/php-icons.
Requires
- php: >=8.1
- yassinedoghri/php-icons: ^v1.0.0
Requires (Dev)
- codeigniter/phpstan-codeigniter: ^1.4.3.70400
- codeigniter4/framework: ^4.3.5
- pestphp/pest: ^2.35.1
- pestphp/pest-plugin-type-coverage: ^2.8.6
- phpstan/extension-installer: ^1.4.3
- phpstan/phpstan: ^1.12.5
- rector/rector: ^1.2.5
- symplify/coding-standard: ^12.2.3
- symplify/easy-coding-standard: ^12.3.5
This package is auto-updated.
Last update: 2025-01-14 11:37:49 UTC
README
CodeIgniter Icons 🔥 🙂
A CodeIgniter4 library with convenient helper functions to render svg icons using php-icons.
🚀 Getting started
0. Prerequisites
Usage of CodeIgniter Icons requires the following:
- A CodeIgniter 4.3.5+ based project
- Composer for package management
- PHP 8.1+
1. Install via composer
composer require yassinedoghri/codeigniter-icons
2. Setup
-
init and configure PHPIcons, ie. create the PHPIcons config file.
-
add icons helper to your
app/Config/Autoload.php
file:
public $helpers = [/*...other helpers...*/, 'icons'];
3. Usage
Use the icon(string $iconKey, array $attributes)
helper function in your View
files to render svg icons:
<?= icon('material-symbols:bolt') ?> // <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"> // <path fill="currentColor" d="m8 22l1-7H4l9-13h2l-1 8h6L10 22z"/> // </svg> <?= icon('material-symbols:bolt', ['class' => 'text-2xl', "style" => "color: yellow;"]) ?> // <svg class="text-2xl" style="color: yellow;" [...]>...</svg> <?= icon('material-symbols:bolt') ->attr('class', 'text-2xl') ->attr('style', 'color: yellow;') ?> // <svg class="text-2xl" style="color: yellow;" [...]>...</svg>
For more usage info, see php icons docs.
⚙️ Configuration
Checkout PHPIcons config reference to tweak things as you please.
// new file - app/Config/Icons.php <?php declare(strict_types=1); namespace Config; // ... use CodeIgniterIcons\Config\Icons as CodeIgniterIcons; class Icons extends CodeIgniterIcons { public string $phpIconsConfigPath = ROOTPATH . 'php-icons.php'; }
📜 License
Code released under the MIT License.
Copyright (c) 2024-present, Yassine Doghri (@yassinedoghri).