{"id":15982223,"url":"https://github.com/yassinedoghri/php-icons","last_synced_at":"2025-03-17T22:31:36.982Z","repository":{"id":229660281,"uuid":"776748931","full_name":"yassinedoghri/php-icons","owner":"yassinedoghri","description":"A php library based on iconify's API to download and render svg icons from popular open source icon sets.","archived":false,"fork":false,"pushed_at":"2024-11-06T11:14:58.000Z","size":122,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-02-28T05:48:09.465Z","etag":null,"topics":["iconify","icons","php-library","svg-icons"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yassinedoghri.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-24T11:37:58.000Z","updated_at":"2025-01-03T16:42:52.000Z","dependencies_parsed_at":"2024-04-08T12:52:48.101Z","dependency_job_id":"ac84c3cb-6281-4034-997f-5e83f2ff87d6","html_url":"https://github.com/yassinedoghri/php-icons","commit_stats":{"total_commits":20,"total_committers":3,"mean_commits":6.666666666666667,"dds":"0.15000000000000002","last_synced_commit":"25530661989860a225f13b6c92c1ee1d2784f9d1"},"previous_names":["yassinedoghri/php-iconify","yassinedoghri/php-icons"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yassinedoghri%2Fphp-icons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yassinedoghri%2Fphp-icons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yassinedoghri%2Fphp-icons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yassinedoghri%2Fphp-icons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yassinedoghri","download_url":"https://codeload.github.com/yassinedoghri/php-icons/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814893,"owners_count":20352038,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["iconify","icons","php-library","svg-icons"],"created_at":"2024-10-08T01:01:45.820Z","updated_at":"2025-03-17T22:31:36.974Z","avatar_url":"https://github.com/yassinedoghri.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# PHPIcons 🐘 🙂\n\n**A convenient PHP library to render svg icons.**\n\n[![Latest Stable Version](https://poser.pugx.org/yassinedoghri/php-icons/v)](https://packagist.org/packages/yassinedoghri/php-icons)\n[![Total Downloads](https://poser.pugx.org/yassinedoghri/php-icons/downloads)](https://packagist.org/packages/yassinedoghri/php-icons)\n[![codecov](https://codecov.io/gh/yassinedoghri/php-icons/graph/badge.svg?token=P8CG7J5HOQ)](https://codecov.io/gh/yassinedoghri/php-icons)\n[![License](https://img.shields.io/github/license/yassinedoghri/php-icons?color=green)](https://packagist.org/packages/yassinedoghri/php-icons)\n[![PHP Version Require](https://poser.pugx.org/yassinedoghri/php-icons/require/php)](https://packagist.org/packages/yassinedoghri/php-icons)\n\n\u003c/div\u003e\n\nGet access to over 200,000 icons from more than\n[150 open source icon sets](https://icon-sets.iconify.design/) directly from\nyour php files!\n\nThanks to [Iconify](https://iconify.design/) ❤️\n\n## 🚀 Getting started\n\n### 1. Install via composer\n\n```sh\ncomposer require yassinedoghri/php-icons\n```\n\n### 2. Configure\n\nRun the following command to initialize the configuration file:\n\n```sh\nvendor/bin/php-icons init\n```\n\nThis will prompt you to create a `php-icons.php` config file in the root of your\nproject. See [config reference](#⚙️-config-reference) for more info.\n\n### 3. Use anywhere\n\n#### 3.1. `icon(string $iconKey, array $attributes)` function\n\nUse the global `icon(…)` function in your view files with the icon key\n(`{prefix}:{icon}`) as parameter:\n\n- `{prefix}`: is the\n  [icon set prefix](https://iconify.design/docs/icons/icon-set-basics.html#naming)\n- `{name}`: is the\n  [icon name](https://iconify.design/docs/icons/icon-basics.html#icon-names)\n\n```php\necho icon('material-symbols:bolt');\n// \u003csvg xmlns=\"http://www.w3.org/2000/svg\" width=\"1em\" height=\"1em\" viewBox=\"0 0 24 24\"\u003e\n//      \u003cpath fill=\"currentColor\" d=\"m8 22l1-7H4l9-13h2l-1 8h6L10 22z\"/\u003e\n// \u003c/svg\u003e\n```\n\n👉 To add attributes, use the second parameter or call the `attr()` or\n`attributes()` methods:\n\n```php\necho icon('material-symbols:bolt', [\n        'class' =\u003e 'text-2xl',\n        'style' =\u003e 'color: yellow;'\n     ]);\n// \u003csvg class=\"text-2xl\" style=\"color: yellow;\" […]\u003e…\u003c/svg\u003e\n\necho icon('material-symbols:bolt')\n      -\u003eattr('class', 'text-2xl')\n      -\u003eattr('style', 'color: yellow;');\n// \u003csvg class=\"text-2xl\" style=\"color: yellow;\" […]\u003e…\u003c/svg\u003e\n\necho icon('material-symbols:bolt')\n      -\u003eattributes([\n        'class' =\u003e 'text-2xl',\n        'style' =\u003e 'color: yellow;'\n      ]);\n// \u003csvg class=\"text-2xl\" style=\"color: yellow;\" […]\u003e…\u003c/svg\u003e\n```\n\n\u003e [!TIP]  \n\u003e Find and copy the icon keys of popular open source icon sets from\n\u003e [Iconify's index](https://icon-sets.iconify.design/).\n\n#### 3.2. Scan source files to load icons\n\n\u003e [!IMPORTANT]  \n\u003e When first defining icons, a placeholder (`�` by default) will be displayed.\\\n\u003e Make sure to run the `scan` command to load the SVGs.\n\n```sh\nvendor/bin/php-icons scan\n```\n\nThe `scan` command will perform a static analysis of all PHP files in your\n[configured paths](#paths) to identify icon keys (`{prefix}:{name}`) and\ndownload the corresponding icons.\n\nUsing the `icon` identifier by default:\n\n1. `icon(…)` functions\n\n   ```php\n    echo icon('ri:php-fill')    // identified \"ri:php-fill\"\n   ```\n\n2. `@icon(…)` annotations in comments\n\n   ```php\n     // @icon('ri:heart-fill') --\u003e identified \"ri:heart-fill\"\n\n     # @icon('ri:home-fill')   --\u003e identified \"ri:home-fill\"\n\n     /*\n      * @icon('ri:user-fill')  --\u003e identified \"ri:user-fill\"\n      * @icon('ri:group-fill') --\u003e identified \"ri:group-fill\"\n      */\n   ```\n\n## ⚙️ Config reference\n\nYour config file is loaded by both the `php-icons` CLI tool and PHPIcons class,\nit should look like this:\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse PHPIcons\\Config\\PHPIconsConfig;\n\nreturn PHPIconsConfig::configure()\n    -\u003ewithPaths([\n      __DIR__ . '/src'\n    ])\n    -\u003ewithDefaultPrefix('')\n    -\u003ewithPlaceholder('�');\n```\n\n### Paths\n\n`withPaths([])`\n\nList of paths to your source files. PHP files will be parsed and scanned for\ndiscovering the icons you have defined.\n\n### API Hosts\n\n`withAPIHosts([])`\n\n[Iconify API](https://iconify.design/docs/api/) hosts to query for downloading\nsvg icons. Starts by querying the first host, the rest is used as backup.\n\nDefaults to Iconify's public hosts:\n`[\"https://api.iconify.design\",\"https://api.simplesvg.com\", \"https://api.unisvg.com\"]`\n\n### Local Icon Sets\n\n`withLocalIconSets([])`\n\nIf you have custom icons, php-icons can look them up locally in your file system\ninstead of calling for the [Iconify API](https://iconify.design/docs/api/).\n\n\u003e [!IMPORTANT]  \n\u003e php-icons will look for `{name}.svg` files in your local icon sets\n\nTakes in an associative array with the icon set prefix as the key and its path\nas value.\n\n#### Example\n\n```\nmy-custom-set/\n├── heart.svg\n├── rocket.svg\n├── star.svg\n└── user.svg\n```\n\n```php\n// in your config file\n-\u003ewithLocalIconSets([\n  'custom' =\u003e '/path/to/my-custom-set',\n])\n```\n\n```php\n// ✅ ALL GOOD\necho icon('custom:heart');\necho icon('custom:rocket');\necho icon('custom:star');\necho icon('custom:user');\n\n// ❌ ICONS NOT FOUND\necho icon('custom:banana');\necho icon('custom:key');\n```\n\n### Default Prefix\n\n`withDefaultPrefix('')`\n\nDefault icon set prefix to use when none is set.\n\n#### Example\n\nWith `material-symbols` set as default prefix:\n\n```php\n// this\necho icon('bolt');\n\n// same as this\necho icon('material-symbols:bolt');\n```\n\n### Default Icon\n\n`withDefaultIcon()`\n\nDefault icon to use when an icon has not been found.\n\nTakes in an icon key `{prefix}:{name}`. If a prefix is not set, the default\nprefix will be used instead.\n\n### Default Icon Per Set\n\n`withDefaultIconPerSet([])`\n\nDefault icon to use when an icon has not been found in a set.\n\nTakes in an associative array, with the key being the icon set prefix, and the\nvalue being the default icon.\n\n### Placeholder\n\n`withPlaceholder('�')`\n\nString to show when icon is not found or unknown.\n\nDefaults to `�` (REPLACEMENT CHARACTER).\n\n### Identifiers\n\n`withIdentifiers([])`\n\nFunction or method names to match for identifying icon keys in your source\nfiles.\n\nDefaults to `['icon']`.\n\n## 🖥️ CLI commands\n\n```sh\n\u003e vendor/bin/php-icons\n\n         _             _\n   _ __ | |__  _ __   (_) ___ ___  _ __  ___\n  | '_ \\| '_ \\| '_ \\  | |/ __/ _ \\| '_ \\/ __|\n  | |_) | | | | |_) | | | (_| (_) | | | \\__ \\\n  | .__/|_| |_| .__/  |_|\\___\\___/|_| |_|___/\n  |_|         |_|\n\n A convenient PHP library to render svg icons\n----------------------------------------------\n\nPHPIcons, version 1.0.0.0-dev\n\nCommands:\n*\n  init i    Configure PHPIcons interactively\n  scan s    Scans source files and loads icons\n\nRun `\u003ccommand\u003e --help` for specific help\n```\n\n## ❤️ Acknowledgments\n\nThis wouldn't have been possible without the awesome work from the\n[Iconify](https://iconify.design/) team and designers that maintain\n[the many open source icon sets](https://icon-sets.iconify.design/).\n\nInspired by [astro-icon](https://www.astroicon.dev/),\n[blade-icons](https://blade-ui-kit.com/blade-icons) and\n[rector](https://getrector.com/).\n\n## 📜 License\n\nCode released under the [MIT License](https://choosealicense.com/licenses/mit/).\n\nCopyright (c) 2024-present, Yassine Doghri\n([@yassinedoghri](https://yassinedoghri.com/)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyassinedoghri%2Fphp-icons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyassinedoghri%2Fphp-icons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyassinedoghri%2Fphp-icons/lists"}