Download the PHP package mahocommerce/directory-data without Composer

On this page you can find all versions of the php package mahocommerce/directory-data. 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 directory-data

Directory Data: Multilingual Countries, Regions & Address Formats

A data package for international e-commerce: country/region names in 100+ locales plus per-country address format metadata (postcode regex, required fields, format templates), all distributed as plain JSON, framework-agnostic.

What This Provides

countries.json

249 ISO 3166-1 countries with multilingual names:

regions/{CC}.json

Shipping-relevant administrative subdivisions per country, multilingual:

formats/{CC}.json

Per-country address format metadata sourced from Google's libaddressinput:

Field semantics follow the libaddressinput conventions: fmt uses %N (name), %O (organization), %A (street), %Z (postcode), %C (city), %S (subdivision), %n (newline); require lists required field codes; upper lists fields that should be uppercased.

Installation

Reading the Data

Use Maho\DirectoryData\Paths to resolve file locations; never hardcode vendor/mahocommerce/directory-data/... since consumers may customize Composer's vendor-dir.

Translation Lookup (countries.json + regions/*.json)

To keep file sizes minimal, redundant translations are omitted. Apply this fallback chain when reading:

  1. Exact locale (e.g. it_IT)
  2. Language code (e.g. it)
  3. en (always present)

When to Use regions/ vs formats/

Both files carry subdivision data, with different purposes and coverage. Pick based on what you're building:

regions/ is the canonical list for display; formats/'s subdivisions map is the canonical source for postal rules. The two overlap intentionally.

Beyond strict ISO 3166-2

regions/ is built primarily from iso-codes (ISO 3166-2 with 100+ locale translations) plus a small curated set of real postal jurisdictions ISO doesn't cover. The most notable case is US: regions/US.json includes the 50 states + DC + Outlying Areas (PR, GU, VI, AS, MP, UM) + military APO codes (AA, AE, AP). The military codes are sourced from libaddressinput; the territories come from broader iso-codes subdivision types. Note that PR/GU/VI/AS/MP/UM are also separately listed as ISO 3166-1 countries; the dual-listing matches libaddressinput's convention and lets merchants pick the model that fits their checkout flow.

Similar augmentations exist for AU (Jervis Bay Territory), NO (Svalbard / Jan Mayen), ES (Ceuta / Melilla), BR (Brasília), MX (Ciudad de México), AR (CABA), KR (Jeju / Gangwon / Sejong), and BS (New Providence).

A note on UK addresses: regions/GB.json lists the 4 UK Constituent Countries (England, Scotland, Wales, Northern Ireland). Real-world UK checkout flows don't actually use a region dropdown: Royal Mail routes by postcode alone, so most major platforms (Magento, WooCommerce, Shopify, BigCommerce, PrestaShop) ship no GB regions and treat county as an optional free-text field after a postcode lookup. The 4 entries here are provided as a minimal option for merchants who do want a dropdown; most won't need them. UK counties (~48 ceremonial or 200+ current administrative units) are deliberately not provided; there's no canonical merchant-facing list and the prevailing convention is to skip the dropdown entirely.

Versioning

Releases use the scheme 1.0.YYYYMMDD:

Pin with ^1.0 to receive non-breaking updates automatically.

Automated Updates

A weekly GitHub Action regenerates the data from upstream sources and, if anything changed and validation passes, commits to main and tags a new release. Packagist picks up new tags via webhook.

Data Attribution & Licensing

Repository code is MIT. Data files carry their upstream licenses; see LICENSE for the full attribution table. Summary:

Files Source License
countries.json, regions/*.json Debian iso-codes via sokil/php-isocodes LGPL-2.1+ / MIT
formats/*.json Google libaddressinput (via chromium-i18n.appspot.com) CC-BY 4.0

Redistributors of the formats/*.json files must preserve attribution to Google's libaddressinput per CC-BY 4.0.


All versions of directory-data with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
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 mahocommerce/directory-data contains the following files

Loading the files please wait ...