Download the PHP package toobo/bcp47 without Composer

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

BCP 47

PHP helpers to validate and normalize IETF BCP 47 language tag.


Static Analysis Unit Tests Code Coverage PHP Version Mutation Tests


Utility functions

The Bcp47Tag class

The Toobo\Bcp47Tag class offers an API similar to the utility functions, but it ensures it encapsulates a valid tag, because it throws when instantiated with an invalid tag.

The class is Stringable and JsonSerializable, and it also implements the Bcp47Code interface defined by the wikimedia/bcp-47-code package.

Validation

The Bcp47Tag class, as well as the Bcp47::isValidTag(), Bcp47::filterTag(), and Bcp47::splitTag() functions, all do validation.

The class throw on instantiation for invalid tags, while the functions returns, respectively, false, null, and an array with all empty items.

The validation is not just about the format but also the actual values. For example, xy-IT looks like a valid tag, but the language "xy" does not exist, so the the tag is not valid.

The validation apply to all subtags (but "extension" and "privateUse"), and also across subtags. For example, the tag ca-valencia is valid (Valencia variant of the Catalan language), but en-valencia is not, despite the language "en" and the variant "valencia" being valid per-se, because there is no "valencia" variant for the English language.

Validation is done by comparing the values with the up-to-date list of all the registered BCP 47 subtags, which includes over 8000 languages, and several hundreds of scripts, regions, and variants.

Normalization

The Bcp47Tag class, as well as both Bcp47::filterTag() and Bcp47::splitTag() functions "normalize" the given tag.

Normalization includes:

FAQ

This package's utility functions are stateless and pure PHP functions.

However, plain PHP functions can't be autoloaded. By using a case-less PHP enum, we get autoloading, but unlike when using a class, we prevent anyone to extend or instantiate the class without intervening on the runtime code.

A case-less PHP enum is a de facto autoload-enabling namespace for functions.

Installation

Best served via Composer, the package name is toobo/bcp47.

Requirements

BCP 47 requires PHP 8.3+, and requires via Composer:

When installed for development, it also requires via Composer:

Security Issues

If you have identified a security issue, please email giuseppe.mazzapica [at] gmail.com and do not file an issue as they are public.

License

Copyright (c), Giuseppe Mazzapica, and contributors.

This software is released under the "MIT" license.


All versions of bcp47 with dependencies

PHP Build Version
Package Version
Requires php Version >= 8.3 < 8.5
wikimedia/bcp-47-code Version ^1|^2
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 toobo/bcp47 contains the following files

Loading the files please wait ....