Download the PHP package lhcze/bcp47-tag without Composer

On this page you can find all versions of the php package lhcze/bcp47-tag. 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 bcp47-tag

🌐 BCP47Tag

πŸͺ Don’t panic. Your tag is valid.

Validate, Normalize & Canonicalize BCP 47 Language Tags (en, en-US, zh-Hant-CN, etc.)

License PHP GitHub Actions Workflow Status Packagist Downloads IANA Registry

BCP47Tag is a robust PHP library for working with BCP 47 language tags:

However, it does not:

If you’re in Symfony, you might also use #[Assert\Locale] for basic input validation.
And that’s fine for checking user input β€” but it stops at structure. It won’t canonicalize, resolve, or check IANA.

πŸ‘‰ So the best practice:

BCP47Tag: RFC 5646 + IANA + real normalization + fallback + resolution.
No hustle with regex, str_replace() or guesswork.


⚑️ Installation


πŸš€ Basic Usage


πŸ” Features & Flow

  1. Normalize + parse
    Clean casing/formatting and parse into components.

  2. Validate against IANA
    Broken input or fallback triggers explicit exceptions:

    • BCP47InvalidLocaleException
    • BCP47InvalidFallbackLocaleException
  3. Canonical matching (optional)

    • Pass an array of useCanonicalMatchTags
    • Each is matched and scored:
      +100 language match, +10 region, +1 script
    • Highest score wins.
    • Same score makes the first one to have it to make a home run
  4. LanguageTag VO
    Immutable, validated, Stringable & JsonSerializable.

πŸ“œ Supported Tags

BCP47Tag uses a precompiled static PHP snapshot of the latest IANA Language Subtag Registry to validate languages, scripts, regions, variants, and grandfathered tags. The registry is loaded once per process, kept hot in OPcache for maximum speed.


🧩 Key API

Method Description
__construct(string $input, ?string $fallback, ?array $useCanonicalMatchTags) Main entry
getInputLocale() Original input string
getNormalized() RFC‑5646 formatted tag
getICUformat() Underscore variant (xx_XX)
getLanguageTag() Returns LanguageTag VO
__toString() / jsonSerialize() Returns normalized string

πŸ“œ The Official BCP 47 ABNF

The syntax tags must follow is defined by RFC 5646 in ABNF:

Examples:

BCP47Tag respects this ABNF, so your tags match the real spec β€” no hidden assumptions.


❓ Why is this useful?

Use cases include:


βš™οΈ Requirements


πŸ§ͺ Tests


πŸ“Œ Roadmap


πŸ“– License

MIT


πŸ”— References


🧬 Now go and boldly canonicalize strange new tags the BCP 47 way! 🌍✨


All versions of bcp47-tag with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
ext-intl Version *
ext-curl Version *
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 lhcze/bcp47-tag contains the following files

Loading the files please wait ...