Download the PHP package nepada/phone-number-input without Composer

On this page you can find all versions of the php package nepada/phone-number-input. 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 phone-number-input

Phone number form input

Build Status Coverage Status Downloads this Month Latest stable

Installation

Via Composer:

Option A: install form container extension method via DI extension

It will register extension method addPhoneNumber($name, $label = null, ?string $defaultRegionCode = null): PhoneNumberInput to Nette\Forms\Container.

Option B: use trait in your base form/container class

You can also use PhoneNumberInputMixin trait in your base form/container class to add method addPhoneNumber($name, $label = null, ?string $defaultRegionCode = null): PhoneNumberInput.

Example:

Usage

PhoneNumberInput is form control that uses phone number value object to represent its value (see brick/phonenumber for further details). It automatically validates the user input and getValue() method always returns PhoneNumber instance, or null if the input is not filled.

Validation

The default validation is fairly lenient - it performs only basic check based on the parsed region and the length of the number.

Strict validation

You can add a more strict validation rule PhoneNumberInput::VALID_STRICT. This rule validates the content against regular expressions from metadata database.

Warning: you must make sure you've got up-to-date metadata library, otherwise you risk running into false positives and false negatives during the validation. The metadata are provided by giggsey/libphonenumber-for-php for backend validation and libphonenumber-js for client side validation.

Region validation

You can restrict the input to accept only numbers from specific region(s):

Default region code

When creating the input you may specify default region code (ISO 3166-1 alpha-2 country code), e.g. $form->addPhoneNumber('phone', 'Phone', 'CZ'). This has two effects: 1) User may omit the country code prefix for this region in the input field, e.g. 212 345 678 is interpreted as +420 212 345 678. 2) When rendering the input, phone numbers for this region are displayed in national format instead of international, i.e. the country code is omitted.

Client side validation

This package comes with client side validation built on top of libphonenumber-js. It is published as npm package @nepada/phone-number-input.

libphonenumber-js provides several different metadata sets. You should choose the one based on your validation needs (e.g. if you don't need strict validation, go with min), or build your own custom metadata set.

Using precompiled bundle

Using precompiled bundles is the quick'n'dirty way of getting client side validation to work.

Building your own bundle

It is highly recommended to install the client side package via nmp and compile your own bundle. This way you can use your custom build of metadata set mentioned earlier.

Here is an example script for initialization of phone number input and Nette forms.


All versions of phone-number-input with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1.0 <8.4
brick/phonenumber Version ^0.2.1@dev || ^0.3@dev || ^0.4@dev || ^0.5@dev || ^0.6@dev
nette/utils Version ^3.2@dev || ^4.0@dev
nette/forms Version ^3.1@dev
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 nepada/phone-number-input contains the following files

Loading the files please wait ....