Download the PHP package brick/phonenumber without Composer

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

Brick\PhoneNumber

A phone number library for PHP.

Build Status Coverage Status Latest Stable Version Total Downloads License

This library is a thin wrapper around giggsey/libphonenumber-for-php, itself a port of Google's libphonenumber.

It provides an equivalent functionality, with the following implementation differences:

Installation

This library is installable via Composer:

Requirements

This library requires PHP 8.1 or later.

For PHP 7.4 and PHP 8.0 support, use version 0.5. For PHP 7.1 support, use version 0.4. For PHP 5.6 and PHP 7.0 support, use version 0.1. Note that these PHP versions are EOL and not supported anymore. If you're still using one of these PHP versions, you should consider upgrading as soon as possible.

Project status & release process

While this library is still under development, it is well tested and should be stable enough to use in production environments.

The current releases are numbered 0.x.y. When a non-breaking change is introduced (adding new methods, optimizing existing code, etc.), y is incremented.

When a breaking change is introduced, a new 0.x version cycle is always started.

It is therefore safe to lock your project to a given release cycle, such as 0.6.*.

If you need to upgrade to a newer release cycle, check the release history for a list of changes introduced by each further 0.x.0 version.

Quick start

All the classes lie in the Brick\PhoneNumber namespace.

To obtain an instance of PhoneNumber, use the parse() method:

Validating a number

The parse() method is quite permissive with numbers; it basically attempts to match a country code, and validates the length of the phone number for this country.

If a number is really malformed, it throws a PhoneNumberParseException:

In most cases, it is recommended to perform an extra step of validation with isValidNumber() or isPossibleNumber():

As a rule of thumb, do the following:

Formatting a number

Basic formatting

You can use format() with a PhoneNumberFormat enum value:

Formatting to call from another country

You may want to present a phone number to an audience in a specific country, with the correct international prefix when required. This is what formatForCallingFrom() does:

Number types

In certain cases, it is possible to know the type of a phone number (fixed line, mobile phone, etc.), using the getNumberType() method, which returns a PhoneNumberType enum value:

If the type is unknown, the PhoneNumberType::UNKNOWN value is returned. Check the PhoneNumberType enum for all possible values.

Number information

You can extract the following information from a phone number:

Example numbers

You can get an example number for a country code and an optional number type (defaults to fixed line). This can be useful to use as a placeholder in an input field, for example:

The return type of getExampleNumber() is a PhoneNumber instance, so you can format it as you like:

If no example phone number is available for the country code / number type combination, a PhoneNumberException is thrown.

Casting to string

Casting a PhoneNumber to string returns its E164 representation (+ followed by digits), so the following are equivalent:

You can serialize a PhoneNumber to string, then recover it using parse() without a country code:

Doctrine mappings

You can use PhoneNumber objects in your Doctrine entities using the brick/phonenumber-doctrine package.


All versions of phonenumber with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
giggsey/libphonenumber-for-php Version ^7.0 || ^8.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 brick/phonenumber contains the following files

Loading the files please wait ....