Download the PHP package cheesegrits/filament-phone-numbers without Composer

On this page you can find all versions of the php package cheesegrits/filament-phone-numbers. 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 filament-phone-numbers

A Filament PHP plugin for normalizing phone numbers

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides a PhoneNumber field, PhoneNumberColumn and PhoneNumberEntry Infolist entry for normalizing, formatting, masking and validating phone numbers in the Filament PHP application builder for Laravel. It also provides an Artisan command for normalizing any phone number data already captured in the database.

It ensures that numbers persisted to the database are in a normalized format, typically E164 (+12345551212), and displays them in National or International format. It supports most of the regional formats by ISO country code.

Think of phone numbers like dates. Regardless of the format you display and input them, you always want them stored in a standard format.

NOTE - if you would rather handle normalizing by casting attributes in your models, and don't need the additional features like normalization of existing data, improved searching and validation this plugin provides, you may prefer to use the excellent Laravel-Phone package.

Installation

NOTE that this package is currently only compatible with Filament v3, and there are currently no plans to release a v2 compatible version.

You can install the package via composer:

You can publish the config file with:

This is the contents of the published config file:

These configuration values define the defaults for all usage of the field and column. They can be overridden on a per field or column basis.

Rather than publishing the config, we recommend using the environment variables.

FILAMENT_PHONE_NUMBERS_ISO_COUNTRY - the standard two letter (alpha-2) ISO country code.

FILAMENT_PHONE_NUMBERS_DATABASE_FORMAT, FILAMENT_PHONE_NUMBERS_DDISPLAY_FORMAT - one of the following integers:

We strongly recommend leaving the database format as E164.

FILAMENT_PHONE_NUMBERS_ICON - any valid Heroicons v2 icon name.

PhoneNumber Field

The simplest usage of the PhoneNumber field is:

This will use your globally configured region, database and display formats.

It will attempt to set a mask based on your region, and will automatically validate the number according to the configured region in "permissive" mode, where it just checks that the number has the correct number of digits.

The full set of options is as follows.

To override the display or database formats, use one of the available PhoneFormat enums:

To enforce a stricter validation, which uses published metadata to determine if a number is "possible", use the strict() method.

Take care using this feature, as metadata may not be fully up-to-date.

To override the globally configured region, use the region() method with a valid two letter (alpha-2) ISO country code.

If the mask automatically applied by the field doesn't do what you want, you can override it with the standard Filament mask() method:

PhoneNumberColumn

The basic usage of the PhoneNumberColumn is:

With no modification, this will use the global default for display format and region.

You may override the format and region, and optionally specify the dial() method, which will render the number as a clickable 'tel' URI:

Searching

With phone numbers normalized to E164, searching for formatted numbers wouldn't usually work out-of-box. For example searching for 555-1212 wouldn't find the number +12345551212. Likewise, searching for (234) won't find it.

To overcome this, we override the default behavior of searchable(). First we check to see if the first character the user typed is an open paren, '('. If so, we assume they are looking for an area code. So we strip any parens, get the country dial code for the currently configured region, and prepend that to the search string. Then we strip all other non-numeric characters from the string. So a search for '(2' with a region of 'US' would get converted to +12. Or '(234) 5' would be '+12345'. If no () are used, we don't prepend the country code, and simply strip non-numeric characters. So 555-1212 becomes 5551212.

If you do not wish to use this behavior (for example if you are not using E164 for your database format, although we strongly recommend that you do) you can add the useDefaultSearch() method, which will bypass the search query modification. Also, if you specify your own $query in a searchable() method, this will bypass our modification.

PhoneNumberEntry

The basic usage of the PhoneNumberEntry Infolist field is as follows:

With no modification, this will use the global default for display format and region.

You may override the format and region, and optionally specify the dial() method, which will render the number as a clickable 'tel' URI:

Artisan Command

We provide an Artisan command for normalizing phone numbers you have already collected in your database table(s).

This will run the command in test mode, whereby no actual changes will be made.

You will be prompted for:

The command will output feedback like this:

If you wish to remove invalid nunbers from your table, you can provide the --delete-invalid option, which will set invalid numbers to null. NOTE that your database field must be nullable for this to work.

Once you are satisfied that the changes are correct, you can call the command with the --commit option:

... or ...

You can also provide all of the arguments on the command line, if you would rather not be prompted for them, as per the following examples.

Testing

Clone the repo and run ...

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

This plugin also uses the Brick\PhoneNumber package by Benjamin Morel, which itself iss a wrapper around the giggsey/libphonenumber-for-php package, which in turn is based on Google's google/libphonenumber package. Turtles all the way down.

License

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


All versions of filament-phone-numbers with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
brick/phonenumber Version ^0.5.0
calebporzio/sushi Version ^2.4
filament/filament Version ^3.0
illuminate/contracts Version ^10.0
spatie/laravel-package-tools Version ^1.15.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 cheesegrits/filament-phone-numbers contains the following files

Loading the files please wait ....