Download the PHP package misd/phone-number-bundle without Composer

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

PhoneNumberBundle

This package has been abandoned in favour of odolbeau/phone-number-bundle.

Build Status Total Downloads Downloads per month Latest stable version License

This bundle integrates Google's libphonenumber into your Symfony2-Symfony4 application through the giggsey/libphonenumber-for-php port.

Installation

  1. Use Composer to download the PhoneNumberBundle:

  2. Register the bundle in your application:

Usage

Services

The following services are available:

Service ID libphonenumber version
libphonenumber\PhoneNumberUtil libphonenumber.phone_number_util
libphonenumber\geocoding\PhoneNumberOfflineGeocoder libphonenumber.phone_number_offline_geocoder >=5.8.8
libphonenumber\ShortNumberInfo libphonenumber.short_number_info >=5.8
libphonenumber\PhoneNumberToCarrierMapper libphonenumber.phone_number_to_carrier_mapper >=5.8.8
libphonenumber\PhoneNumberToTimeZonesMapper libphonenumber.phone_number_to_time_zones_mapper >=5.8.8

So to parse a string into a libphonenumber\PhoneNumber object:

Doctrine mapping

Requires doctrine/doctrine-bundle.

To persist libphonenumber\PhoneNumber objects, add the Misd\PhoneNumberBundle\Doctrine\DBAL\Types\PhoneNumberType mapping to your application's config:

You can then use the phone_number mapping:

This creates a varchar(35) column with a Doctrine mapping comment.

Note that if you're putting the phone_number type on an already-existing schema the current values must be converted to the libphonenumber\PhoneNumberFormat::E164 format.

Templating

Twig

phone_number_format

The phone_number_format filter can be used to format a phone number object. A libphonenumber\PhoneNumberFormat constant can be passed as argument to specify in which format the number should be printed.

For example, to format an object called myPhoneNumber in the libphonenumber\PhoneNumberFormat::NATIONAL format:

By default phone numbers are formatted in the libphonenumber\PhoneNumberFormat::INTERNATIONAL format.

phone_number_of_type

The phone_number_of_type test can be used to check a phone number against a type: A libphonenumber\PhoneNumberType constant name must be passed to specify to which type a number has to match.

For example, to check if an object called myPhoneNumber is a libphonenumber\PhoneNumberType::MOBILE type:

PHP template

format()

The format() method in the phone_number_helper takes two arguments: a libphonenumber\PhoneNumber object and an optional libphonenumber\PhoneNumberFormat constant name or value.

For example, to format $myPhoneNumber in the libphonenumber\PhoneNumberFormat::NATIONAL format, either use:

or:

By default phone numbers are formatted in the libphonenumber\PhoneNumberFormat::INTERNATIONAL format.

isType()

The isType() method in the phone_number_helper takes two arguments: a libphonenumber\PhoneNumber object and an optional libphonenumber\PhoneNumberType constant name or value.

For example, to check if $myPhoneNumberis alibphonenumber\PhoneNumberType::MOBILE` type:

or:

Serializing libphonenumber\PhoneNumber objects

Requires jms/serializer-bundle.

Instances of libphonenumber\PhoneNumber are automatically serialized in the E.164 format.

Phone numbers can be deserialized from an international format by setting the type to libphonenumber\PhoneNumber. For example:

Using libphonenumber\PhoneNumber objects in forms

You can use the PhoneNumberType (phone_number for Symfony 2.7) form type to create phone number fields. There are two widgets available.

Single text field

A single text field allows the user to type in the complete phone number. When an international prefix is not entered, the number is assumed to be part of the set default_region. For example:

By default the default_region and format options are PhoneNumberUtil::UNKNOWN_REGION and PhoneNumberFormat::INTERNATIONAL respectively.

Country choice fields

The phone number can be split into a country choice and phone number text fields. This allows the user to choose the relevant country (from a customisable list) and type in the phone number without international dialling.

This produces the preferred choices of 'Jersey' and 'United Kingdom', and regular choices of 'France' and 'United States'.

By default the country_choices is empty, which means all countries are included, as is preferred_country_choices. The option country_placeholder can be specified to create a placeholder option on above the whole list.

Validating phone numbers

You can use the Misd\PhoneNumberBundle\Validator\Constraints\PhoneNumber constraint to make sure that either a libphonenumber\PhoneNumber object or a plain string is a valid phone number. For example:

You can set the default region through the defaultRegion property:

By default any valid phone number will be accepted. You can restrict the type through the type property, recognised values:

(Note that libphonenumber cannot always distinguish between mobile and fixed-line numbers (eg in the USA), in which case it will be accepted.)

Translations

The bundle contains translations for the form field and validation constraints.

In cases where a language uses multiple terms for mobile phones, the generic language locale will use the term 'mobile', while country-specific locales will use the relevant term. So in English, for example, en uses 'mobile', en_US uses 'cell' and en_SG uses 'handphone'.

If your language doesn't yet have translations, feel free to open a pull request to add them in!


All versions of phone-number-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.3
giggsey/libphonenumber-for-php Version ~5.7|~6.0|~7.0|~8.0
symfony/framework-bundle Version ~2.1|~3.0|^4.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 misd/phone-number-bundle contains the following files

Loading the files please wait ....