Download the PHP package juanparati/iso-codes without Composer

On this page you can find all versions of the php package juanparati/iso-codes. 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 iso-codes

Test passed

🌐 ISOCodes

What is it?

A PHP library that provides a list of structured ISO codes oriented to geography/geopolitical information.

This library provides the following ISOs and codes:

This library provides localized names for countries, currencies and languages. The library allows to create custom/new locales.

RDMS like MySQL or SQLite is not required in order to use this library. All the data is maintained in separate files that are loaded and linked on demand in a way that keeps a low memory footprint.

Disclaimer

This library data is based on international standards recognized by global organizations, the author is not responsible about how the translations and geopolitical data is represented.

If you feel that this library data doesn't comply with the geopolitical views required by your project, fell free to register a custom dataset.

Composer

composer require juanparati/iso-codes

Laravel

This library is compatible with Laravel 8.x+ however it can work as a standalone library.

Facade registration

'aliases' => [
    ...
    'ISOCodes' => \Juanparati\ISOCodes\Facades\ISOCodesFacade::class,
    ...
]

Configuration

Publish configuration file (Required only when custom dataset or locales are required):

artisan vendor:publish --provider="Juanparati\ISOCodes\Providers\ISOCodesProvider"

Usage

The list of results are returned as Collections.

Country model examples

Get the list of all country codes as an array:

(new ISOCodes)->countries()->toArray();

It returns something like this:

[
...
    "ES"=> [
        "alpha2" => "ES",
        "alpha3" => "ESP",
        "numeric" => "724",
        "tld" => ".es",
        "currencies" => [
          "EUR",
        ],
        "languages" => [
          "ES",
          "CA",
          "GL",
          "EU",
        ],
        "continents" => [
          "EU",
        ],
        "capital" => "Madrid",
        "flag" => "🇪🇸",
        "phone_code" => "34",
        "eu_member" => true,
        "name" => "Spain",
        "timezones" => [
            "Europe/Madrid",
            "Africa/Ceuta",
            "Atlantic/Canary",
        ]
    ]
...
];

Retrieve all the countries as a Collection:

Retrieve one specific country:

or using the shortcut

Retrieve all the countries located in Europe:

Retrieve all the countries located only in Europe:

Retrieve all the countries located in Europe and Asia:

Retrieve all the countries located in Europe or Asia

Retrieve all the countries sorted by numeric code descending that uses only Euro as currency:

or

Retrieve all the countries that uses at least Euro as currency:

Create a list of countries with their names (useful for generate a listbox options):

Retrieve a list of countries that has Portuguese as one of their official languages:

Language model examples

Get the list grouped by language:

It returns something like:

[
...
    "CA" => [
        "code" => "CA",
        "name" => "Catalan",
        "countries" => [
            [
                "alpha2"     => "AD",
                "alpha3"     => "AND",
                "numeric"    => "020",
                "tld"        => ".ad",
                "currencies" => [ …1],
                "languages"  => [ …1],
                "continents" => [ …1],
                "name"       => "Andorra",
                "timezones"  => [
                    "Europe/Andorra"
                ]
            ],
            ...
        ],
        "currencies" => [
            "EUR",
        ],
        "continents" => [
            "EU",
        ],
    ]
...
];

Continent model examples

Get the list grouped by continent.

Example:

Currency model examples

Get the list grouped by currency.

Example:

CurrencyNumber model examples

Get the list grouped by currency number.

Example:

Property access

Each record array member can be accessed using the array and object syntax.

Example:

Each record is serializable, that it make it ideal in order to store the results into a cache.

Use currency numbers instead of currency codes.

The method setCurrencyAsNumber specify if the currency code is returned as a number.

Example:

Node resolution

The method setResolution modify how the associated nodes are structured.

The available nodes are:

The available node formats are:

Examples:

returns the following:

[
    "alpha2"     => "PT",
    "alpha3"     => "PRT",
    "numeric"    => "620",
    "tld"        => ".pt",
    "currencies" => [
        "EUR" => "Euro",
    ],
    "languages"  => [
        "Portuguese",
    ],
    "name"       => "Portugal",
    "capital"    => "Lisboa",
    "flag"       => "🇵🇹",
    "phone_code" => "351",
    "eu_member"  => true,
    "timezones"  => [
        "Europe/Lisbon",
        "Atlantic/Azores",
        "Atlantic/Madeira",
    ],
]

instead of:

[
    "alpha2"     => "PT",
    "alpha3"     => "PRT",
    "numeric"    => "620",
    "tld"        => ".pt",
    "currencies" => [
        "EUR",
    ],
    "languages"  => [
        "PT",
    ],
    "continents" => [
        "EU",
    ],
    "name"       => "Portugal",
    "capital"    => "Lisboa",
    "flag"       => "🇵🇹",
    "phone_code" => "351",
    "eu_member"  => true,
    "timezones"  => [
        "Europe/Lisbon",
        "Atlantic/Azores",
        "Atlantic/Madeira",
    ],
]

The node resolutions works with the others models like "currencies", "languages", etc.

Node resolutions and immutability

When the resolution is changed it will be back to the previous state in the next model call.

Example:

In order to keep persistent the resolutions it's possible to pass the resolution values to the constructor. Example:

Main language and timezone

Custom dataset and locales

It's possible to register custom datasets and locales during the ISOCodes instantiation.

Example:

See the following example with the country names.

Macroable models

The models are macroable so it's possible to inject custom methods.

Example:

Flags representation in client side

Some operating systems and web browsers may not be able to represent unicode flags due political reasons. I recommend to use the libraries like country-flag-emoji-polyfill in order to provide a graphical representation of the flags in the client side.

Contributions

Feel free to add new locales to this library and send me a pull request.


All versions of iso-codes with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-ctype Version *
illuminate/support Version ^8.34.0|^9.0|^10.0|^11.0|^12.0
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 juanparati/iso-codes contains the following files

Loading the files please wait ....