PHPackages                             jonasraoni/marc-to-iso - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jonasraoni/marc-to-iso

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jonasraoni/marc-to-iso
======================

PHP mappings from MARC codes/countries to the ISO 3166-1 alpha-2 format and vice-versa.

1.0.0(4y ago)314MITPHPPHP &gt;=7.2.0

Since Jul 17Pushed 4y ago1 watchersCompare

[ Source](https://github.com/jonasraoni/marc-to-iso)[ Packagist](https://packagist.org/packages/jonasraoni/marc-to-iso)[ Docs](http://github.com/jonasraoni/marc-to-iso)[ RSS](/packages/jonasraoni-marc-to-iso/feed)WikiDiscussions main Synced yesterday

READMEChangelog (1)DependenciesVersions (2)Used By (0)

MARC Countries &lt;=&gt; ISO
============================

[](#marc-countries--iso)

PHP mappings from MARC codes/countries to the ISO 3166-1 alpha-2 format and vice-versa.

Usage
-----

[](#usage)

Install the package:

```
composer require jonasraoni/marc-to-iso

```

The package provides 4 separated mappings (just to decrease the amount of bloat data loaded into memory):

- [JonasRaoni\\MarcToIso\\IsoToMarcCode](src/IsoToMarcCode.php)
- [JonasRaoni\\MarcToIso\\IsoToMarcName](src/IsoToMarcName.php)
- [JonasRaoni\\MarcToIso\\MarcCodeToIso](src/MarcCodeToIso.php)
- [JonasRaoni\\MarcToIso\\MarcNameToIso](src/MarcNameToIso.php)

Choose the one that fits your needs and call the static method `get`, it might return the right mapping or null if it's invalid.

```
use JonasRaoni\MarcToIso\IsoToMarcCode;

echo 'US = ' . IsoToMarcCode::get('US');
```

Data Generation
---------------

[](#data-generation)

To regenerate the classes, ensure the submodules are updated, then call the [generate.php](data/generate.php) script (contains the class template, manual mappings, etc.) and it will overwrite the existing classes.

The process is simple, a [generic list of countries and their respective MARC codes](https://github.com/datasets/country-codes) is matched against the complete [list of MARC codes](data/marc-codes.csv), and the remaining items, which didn't match, are manually mapped.

Data Source
-----------

[](#data-source)

- The generic list of countries was retrieved from this link:  (the .csv is linked to this repository as a submodule).
- The list of MARC countries/codes was manually retrieved from this link: [https://www.loc.gov/marc/countries/countries\_code.html](https://www.loc.gov/marc/countries/countries_code.html). The script below was used to extract a .csv out of the link (it should be executed in a Chromium DevTools console panel), when executed it will copy the data as a CSV to your clipboard.

*The deprecated MARC codes were intentionally removed, since some of them might refer to countries that don't exist anymore, and thus not part of the ISO standard.*

```
let rows = ['code;name'];
for(const tr of [...$$('table:nth-of-type(1) tbody tr')].slice(1)) {
    const code = tr.querySelectorAll('td')[0].innerText;
    const name = tr.querySelectorAll('td')[1].innerText;
    if (!code.includes('-')) // deprecated
        rows.push(code.replace('-', '') + ',' + tr.querySelectorAll('td')[1].innerText);
}
copy(rows.join('\n'));
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1760d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/32c66dd29e4133c60890fd5dede747fd8975f0036c5e1f56f99eb7ebb25ee5df?d=identicon)[jonasraoni](/maintainers/jonasraoni)

---

Top Contributors

[![jonasraoni](https://avatars.githubusercontent.com/u/361921?v=4)](https://github.com/jonasraoni "jonasraoni (2 commits)")

---

Tags

iso3166iso3166-1marc-codesmarc-countriesmarc-to-isophpmappingcountrymarcIso3166

### Embed Badge

![Health badge](/badges/jonasraoni-marc-to-iso/health.svg)

```
[![Health](https://phpackages.com/badges/jonasraoni-marc-to-iso/health.svg)](https://phpackages.com/packages/jonasraoni-marc-to-iso)
```

###  Alternatives

[components/flag-icon-css

A curated collection of all country flags in SVG — plus the CSS for easier integration.

12.0k1.6M23](/packages/components-flag-icon-css)[rinvex/countries

Rinvex Countries is a simple and lightweight package for retrieving country details with flexibility. A whole bunch of data including name, demonym, capital, iso codes, dialling codes, geo data, currencies, flags, emoji, and other attributes for all 250 countries worldwide at your fingertips.

1.7k7.4M48](/packages/rinvex-countries)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[lipis/flag-icons

A curated collection of all country flags in SVG — plus the CSS for easier integration.

12.0k27.5k4](/packages/lipis-flag-icons)[cornford/googlmapper

An easy way to integrate Google Maps with Laravel.

457447.9k4](/packages/cornford-googlmapper)[dougsisk/laravel-country-state

Country &amp; state helper for Laravel.

1681.7M](/packages/dougsisk-laravel-country-state)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
