Download the PHP package iconify/json-tools without Composer

On this page you can find all versions of the php package iconify/json-tools. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package json-tools

Iconify JSON tools

This library is used to manipulate JSON icon collections.

The library is available for PHP and Node.js, code in both versions is almost identical.

Installation

To install the library run this command:

There are two classes in this package: Collection and SVG

Collection class

Collection class represents an icon set.

To include it use this code:

What can Collection class do?

Initializing class instance

There are two ways to create an instance: with icon set prefix and without icon set prefix.

You can skip icon set prefix in the constructor if you are going to load data from a JSON file because JSON files contain icon set prefix.

Loading JSON data

There are several functions to load an icon set from JSON file:

loadFromFile()

This function loads an icon set from a JSON file.

Function parameters:

Returns:

loadJSON()

This function loads an icon set from a string or an array.

Function parameters:

Returns:

loadIconifyCollection()

This function loads Iconify collection from iconify/json repository.

Function parameters:

Returns:

Caching icon sets

PHP loads icon sets on every page load, so it makes sense not to parse the same data many times. This is why PHP version of the library has caching functions.

loadFromCache()

This function loads icon set from the cache.

Function parameters:

Returns:

saveCache()

Stores icon set data in the cache.

This function does not return anything.

For a usable example, see loadFromCache() example above.

Getting icon data

Several functions can be used to retrieve icon data from an icon set:

getIconData()

This function returns JSON data for one icon. It returns full data, including optional fields, so the result can be used to generate SVG.

Function parameters:

Returns:

getIcons()

This function returns JSON data for selected icons. If used without parameters, it returns JSON data for an entire icon set.

Parameters:

This function can also be used to copy collection:

Using $collection->getIcons() without parameters is the same as accessing $collection->items array.

scriptify()

This is similar to getIcons(), but it generates JavaScript file instead of JSON data and parameters are passed as one array.

Function parameters:

Returns:

Options array keys:

Code to create a bundle with selected icons from one collection (repeat same code for different collections to make bundle of all icons used on website):

Adding/removing icons

addIcon()

This function adds a new icon to the icon set.

Function parameters:

Returns:

addAlias()

This function adds an alias for an existing icon.

Function parameters:

Returns:

setDefaultIconValue()

Set default value for all icons.

Function parameters:

removeIcon()

Removes an icon or an alias from the icon set.

Function parameters:

iconExists()

Checks if an icon or an alias exists.

Function parameters:

Returns:

listIcons()

Lists all icons in an icon set.

Function parameters:

Returns:

Other functions

items

This is a property, not a function. You can use it to have access to raw JSON data. Value is the same as using getIcons() without parameters, however editing the result of getIcons() will not affect collection data because it copies array.

Editing the $collection->items array will change collection data.

prefix()

Returns the icon set prefix, false if the icon set has no prefix.

Returns:

findIconifyCollection()

This function locates Iconify icon set from iconify/json repository.

Function parameters:

Returns:

optimize()

Optimize is a static function that optimizes JSON data. It modifies an array passed by reference in the first parameter.

Function parameters:

deOptimize()

Opposite of the previous function. It converts optimized JSON data into full JSON data, making it easy to retrieve data for each icon.

Function parameters:

SVG class

The SVG class generates code for the icon.

To include it use this code:

Initializing class instance

Getting SVG icon

The SVG class has one function: getSVG(). It returns SVG as a string.

getSVG() has one parameter: custom properties array. Possible array keys:

License

The library is released with MIT license.

© 2018 - 2020 Vjacheslav Trushkin


All versions of json-tools with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package iconify/json-tools contains the following files

Loading the files please wait ....