Download the PHP package zentlix/libphonenumber without Composer

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

Google libphonenumber integration package for Spiral Framework

PHP Version Require Latest Stable Version phpunit psalm Codecov Total Downloads type-coverage psalm-level

The package provides tools for parsing, formatting, and validating international phone numbers in Spiral Framework. It integrates the Google libphonenumber library, which is a powerful and widely used library for working with phone numbers.

Requirements

Make sure that your server is configured with following PHP version and extensions:

Installation

To install the package, use Composer by running the following command:

To enable the package in your Spiral Framework application, you will need to add the Spiral\PhoneNumber\Bootloader\PhoneNumberBootloader class to the list of bootloaders in your application:

Note If you are using spiral-packages/discoverer, you don't need to register bootloader by yourself.

Configuration

The configuration file should be located at app/config/libphonenumber.php, and it allows you to set options such as the default region and default format for phone numbers.

Here is an example of how the configuration file might look:

The default_region option specifies the default region code to use when parsing and formatting phone numbers. This can be set to any valid region code, such as US, GB, and others.

The default_format option specifies the default format to use when formatting phone numbers. This can be set to any of the constants provided by the libphonenumber\PhoneNumberFormat class, such as NATIONAL, INTERNATIONAL, or E164.

Usage

The libphonenumber\PhoneNumberUtil class provides methods for parsing phone numbers from strings, formatting phone numbers as strings, and validating phone numbers.

The libphonenumber\PhoneNumber class is a class that represents a phone number in an object-oriented format. It is returned by the parse method of the libphonenumber\PhoneNumberUtil class, and it stores complete phone number information such as the country code, national number, and other details.

One way to use the PhoneNumberUtil class is to inject it into your classes using dependency injection. For example:

Alternatively, you can create a libphonenumber\PhoneNumberUtil instance manually by calling the PhoneNumberUtil::getInstance method. For example:

Here is an example of how you might use some of the methods provided by the libphonenumber\PhoneNumberUtil and libphonenumber\PhoneNumber classes:

Validation

Symfony Validator

The package provides a Spiral\PhoneNumber\Validator\Constraints\PhoneNumber constraint that can be used to validate phone numbers using the spiral-packages/symfony-validator component.

To use the Spiral\PhoneNumber\Validator\Constraints\PhoneNumber constraint, you will first need to make sure that the spiral-packages/symfony-validator package is installed and enabled in your Spiral Framework application.

Once the spiral-packages/symfony-validator package is installed and enabled, you can use the PhoneNumber constraint in your code like this:

In this example, the PhoneNumber constraint is applied to the $phone property of the User class using the attribute. This will cause the Validator to validate the $phone property as a phone number when the User object is validated. If the value of the $phone property is not a valid phone number, the validation will fail.

You can also specify additional options when using the PhoneNumber constraint:

Spiral Validator

The package provides a Spiral\PhoneNumber\Validator\Checker\PhoneNumberChecker checker that can be used to validate phone numbers using the spiral/validator component.

To use the Spiral\PhoneNumber\Validator\Checker\PhoneNumberChecker checker, you will first need to make sure that the spiral/validator package is installed and enabled in your Spiral Framework application.

Once the spiral/validator package is installed and enabled, you can use the PhoneNumberChecker checker in your code like this:

In this example, the PhoneNumberChecker checker is applied to the $phone property of the UserRequest class. This will cause the Validator to validate the $phone property as a phone number when the UserRequest object is validated. If the value of the $phone property is not a valid phone number, the validation will fail.

Serialization

The package provides a Spiral\PhoneNumber\Serializer\Normalizer\PhoneNumberNormalizer class that can be used to serialize and deserialize libphonenumber\PhoneNumber objects using the spiral-packages/symfony-serializer package.

Once the spiral-packages/symfony-serializer package is installed and enabled, the PhoneNumberNormalizer class will be automatically registered as a normalizer for libphonenumber\PhoneNumber objects. This means that you can use the Symfony Serializer to serialize and deserialize libphonenumber\PhoneNumber objects just like any other object:

Twig

The package provides a Spiral\PhoneNumber\Twig\Extension\PhoneNumberExtension class that can be used to add filters and test to the Twig templating engine.

To use the PhoneNumberExtension class, you will first need to make sure that the spiral/twig-bridge package is installed and enabled in your Spiral Framework application.

Once the spiral/twig-bridge package is installed and enabled, the PhoneNumberExtension class will be automatically registered as an extension for Twig.

The PhoneNumberExtension class provides the following filters:

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see License File for more information.


All versions of libphonenumber with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
giggsey/libphonenumber-for-php Version ^8.13
spiral/boot Version ^3.5
spiral/config Version ^3.5
spiral/core Version ^3.5
spiral/attributes Version ^2.14 || ^3.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 zentlix/libphonenumber contains the following files

Loading the files please wait ....