yassinedoghri/codeigniter-iconify

此包已被废弃,不再维护。作者建议使用yassinedoghri/codeigniter-icons包。

一个CodeIgniter4库,包含方便的辅助函数,用于使用yassinedoghri/php-icons渲染svg图标。

v1.0.0 2024-09-29 17:11 UTC

This package is auto-updated.

Last update: 2024-09-29 17:11:49 UTC


README

CodeIgniter Icons 🔥 🙂

一个CodeIgniter4库,包含方便的辅助函数,用于使用php-icons渲染svg图标。

Latest Stable Version Total Downloads License PHP Version Require

🚀 开始使用

0. 前置条件

使用CodeIgniter Icons需要以下条件

  • 基于CodeIgniter 4.3.5+的项目
  • Composer包管理工具
  • PHP 8.1+

1. 通过Composer安装

composer require yassinedoghri/codeigniter-icons

2. 设置

  1. 初始化并配置PHPIcons,即创建PHPIcons配置文件。

  2. 将图标辅助函数添加到您的app/Config/Autoload.php文件中

public $helpers = [/*...other helpers...*/, 'icons'];

3. 使用

在您的视图文件中使用icon(string $iconKey)phpicons(string $iconKey)辅助函数来渲染svg图标

<?= 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>

<?= phpicons('material-symbols:bolt')
        ->attr('class', 'text-2xl')
        ->attr('style', 'color: yellow;') ?>
// <svg class="text-2xl" style="color: yellow;" [...]>...</svg>

有关更多信息,请参阅php图标文档

⚙️ 配置

查看PHPIcons配置参考以调整您所需的内容。

// 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';
}

📜 许可证

代码在MIT许可证下发布。

版权(c)2024-present,Yassine Doghri (@yassinedoghri)。