Skip to content

Commit

Permalink
feat: update php-iconify to php-icons
Browse files Browse the repository at this point in the history
- rename project to codeigniter-icons
- update Config and Service
- update README
  • Loading branch information
yassinedoghri committed Apr 9, 2024
1 parent 5ad3a2d commit 35a7481
Show file tree
Hide file tree
Showing 11 changed files with 533 additions and 961 deletions.
7 changes: 7 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Extending https://github.com/devcontainers/images/blob/main/src/php
FROM "mcr.microsoft.com/devcontainers/php:1-8.2-bullseye"

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

# Add php intl extension
RUN install-php-extensions intl
7 changes: 5 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/php
{
"name": "PHP",
"name": "Codeigniter Icons",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/php:1-8.2-bullseye",
"build": {
// Path is relataive to the devcontainer.json file.
"dockerfile": "Dockerfile"
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [8000],
// Features to add to the dev container. More info: https://containers.dev/features.
Expand Down
70 changes: 23 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# CodeIgniter Iconify 🔥 🙂
# CodeIgniter Icons 🔥 🙂

[![Latest Stable Version](http://poser.pugx.org/yassinedoghri/codeigniter-iconify/v)](https://packagist.org/packages/yassinedoghri/codeigniter-iconify)
[![Total Downloads](http://poser.pugx.org/yassinedoghri/codeigniter-iconify/downloads)](https://packagist.org/packages/yassinedoghri/codeigniter-iconify)
[![Latest Unstable Version](http://poser.pugx.org/yassinedoghri/codeigniter-iconify/v/unstable)](https://packagist.org/packages/yassinedoghri/codeigniter-iconify)
[![License](https://img.shields.io/github/license/yassinedoghri/codeigniter-iconify?color=green)](https://packagist.org/packages/yassinedoghri/codeigniter-iconify)
[![PHP Version Require](http://poser.pugx.org/yassinedoghri/codeigniter-iconify/require/php)](https://packagist.org/packages/yassinedoghri/php-iconify)
[![Latest Stable Version](http://poser.pugx.org/yassinedoghri/codeigniter-icons/v)](https://packagist.org/packages/yassinedoghri/codeigniter-icons)
[![Total Downloads](http://poser.pugx.org/yassinedoghri/codeigniter-icons/downloads)](https://packagist.org/packages/yassinedoghri/codeigniter-icons)
[![Latest Unstable Version](http://poser.pugx.org/yassinedoghri/codeigniter-icons/v/unstable)](https://packagist.org/packages/yassinedoghri/codeigniter-icons)
[![License](https://img.shields.io/github/license/yassinedoghri/codeigniter-icons?color=green)](https://packagist.org/packages/yassinedoghri/codeigniter-icons)
[![PHP Version Require](http://poser.pugx.org/yassinedoghri/codeigniter-icons/require/php)](https://packagist.org/packages/yassinedoghri/codeigniter-icons)

A [CodeIgniter4](https://codeigniter.com/) library with convenient helper
functions to render svg icons using
[php-iconify](https://github.com/yassinedoghri/php-iconify).
[php-icons](https://github.com/yassinedoghri/php-icons).

## 🚀 Getting started

### 0. Prerequisites

Usage of CodeIgniter Iconify requires the following:
Usage of CodeIgniter Icons requires the following:

- A CodeIgniter 4.3.5+ based project
- Composer for package management
Expand All @@ -23,20 +23,24 @@ Usage of CodeIgniter Iconify requires the following:
### 1. Install via composer

```sh
composer require yassinedoghri/codeigniter-iconify
composer require yassinedoghri/codeigniter-icons
```

### 2. Setup

Add iconify helper to the `app/Config/Autoload.php` file:
1. [init and configure PHPIcons](https://github.com/yassinedoghri/php-icons),
ie. create the PHPIcons config file.

2. add icons helper to your `app/Config/Autoload.php` file:

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

### 3. Usage

Use the `icon()` or `iconify()` helpers in your View files to render svg icons:
Use the `icon(string $iconKey)` or `phpicons(string $iconKey)` helpers in your
View files to render svg icons:

```php
<?= icon('material-symbols:bolt') ?>
Expand All @@ -45,46 +49,20 @@ Use the `icon()` or `iconify()` helpers in your View files to render svg icons:
// </svg>

<?= icon('material-symbols:bolt', ['class' => 'text-2xl', "style" => "color: yellow;"]) ?>
// <svg class="text-2xl" 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>
// <svg class="text-2xl" style="color: yellow;" [...]>...</svg>

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

#### Default Icon Pack

> [!TIP]
> Using a consistent icon style throughout your app can help create a cohesive
> look and feel.
👉 This can be achieved by setting a default icon pack in your config
([see configuration below](#⚙️-configuration)).

```php
// your app/Config/Iconify.php config file
//...
public $defaultPack = "material-symbols";
//...
```

This way, no need to specify the icon pack when using the helpers!

```diff
-<?= icon('material-symbols:bolt') ?>
+<?= icon('bolt') ?>
```
For more usage info, see
[php icons docs](https://github.com/yassinedoghri/php-icons).

## ⚙️ Configuration

By default, CodeIgniter Iconify will use Iconify's public APIs to download icons
and cache them into the `app/Resources/icons` folder. You may overwrite this
config with your own `app/Config/Iconify.php` file:
Checkout PHPIcons config reference to tweak things as you please.

```php
// new file - app/Config/Iconify.php
Expand All @@ -99,9 +77,7 @@ use CodeIgniterIconify\Config\Iconify as CodeIgniterIconify;

class Iconify extends CodeIgniterIconify
{
public $apiHosts = [];
public $iconsFolder = APPPATH . 'Resources/icons';
public $defaultPack = "";
public string $phpIconsConfigPath = ROOTPATH . 'php-icons.php';
}
```

Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "yassinedoghri/codeigniter-iconify",
"description": "A CodeIgniter4 library with convenient helper functions to render svg icons using php-iconify.",
"name": "yassinedoghri/codeigniter-icons",
"description": "A CodeIgniter4 library with convenient helper functions to render svg icons using yassinedoghri/php-icons.",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {
"CodeIgniterIconify\\": "src/"
"CodeIgniterIcons\\": "src/"
}
},
"keywords": [
Expand All @@ -24,17 +24,17 @@
],
"require": {
"php": ">=8.1",
"yassinedoghri/php-iconify": "dev-develop"
"yassinedoghri/php-icons": "dev-develop"
},
"require-dev": {
"codeigniter/phpstan-codeigniter": "^v1.4.3",
"codeigniter4/devkit": "^v1.2.1",
"codeigniter4/devkit": "^v1.2.2",
"codeigniter4/framework": "^4.3.5",
"phpstan/extension-installer": "^1.3.1",
"phpstan/phpstan": "^1.10.65",
"rector/rector": "^1.0.3",
"symplify/coding-standard": "^11.4.1",
"symplify/easy-coding-standard": "^11.5.0"
"phpstan/phpstan": "^1.10.66",
"rector/rector": "^1.0.4",
"symplify/coding-standard": "^12.1.4",
"symplify/easy-coding-standard": "^12.1.14"
},
"scripts": {
"dev": "php -S 0.0.0.0:8000",
Expand Down
Loading

0 comments on commit 35a7481

Please sign in to comment.