PHPackages                             visual1au/statamic-phone-fieldtype - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. visual1au/statamic-phone-fieldtype

ActiveStatamic-addon[Validation &amp; Sanitization](/categories/validation)

visual1au/statamic-phone-fieldtype
==================================

A Statamic fieldtype for phone number validation and E.164 formatting using Laravel-Phone with Australia-first detection

v1.0.0(8mo ago)0102MITPHPPHP ^8.1

Since Sep 17Pushed 8mo agoCompare

[ Source](https://github.com/visual1-development/statamic-phone-fieldtype)[ Packagist](https://packagist.org/packages/visual1au/statamic-phone-fieldtype)[ Docs](https://github.com/visual1au/statamic-phone-fieldtype)[ RSS](/packages/visual1au-statamic-phone-fieldtype/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Statamic Phone Number Fieldtype
===============================

[](#statamic-phone-number-fieldtype)

A Statamic fieldtype for phone number validation and E.164 formatting using Laravel-Phone. Perfect for forms and collections that need consistent phone number handling with Australia-first detection.

Features
--------

[](#features)

- ✅ **Multi-format Input**: Accepts various phone formats (0412 345 678, (07) 3210 1234, +61 412 345 678, +1 555 123 4567)
- ✅ **Australia-first Validation**: Validates phone numbers using Laravel-Phone with Australia-first detection
- ✅ **E.164 Normalisation**: Automatically converts valid numbers to E.164 format (e.g. +12345678901)
- ✅ **Form Compatible**: Works in Statamic forms with custom validation messages
- ✅ **Integration Ready**: Ensures consistent format for Zapier, HubSpot, and other integrations
- ✅ **User-Friendly**: Clear error messages with international format examples

Installation
------------

[](#installation)

Install via Composer:

```
composer require visual1au/statamic-phone-fieldtype
```

Requirements
------------

[](#requirements)

- PHP 8.1+
- Statamic 4.0+ or 5.0+
- Laravel-Phone 5.0+ or 6.0+

The package automatically installs `propaganistas/laravel-phone` if not already present.

Configuration
-------------

[](#configuration)

### Environment Variables

[](#environment-variables)

You can configure the phone number validation behavior using environment variables in your `.env` file:

```
# Set the primary country code (ISO 3166-1 alpha-2)
PHONE_FIELDTYPE_PRIMARY_COUNTRY=AU

# Enable/disable automatic fallback detection
PHONE_FIELDTYPE_AUTO_FALLBACK=true
```

### Publishing Configuration

[](#publishing-configuration)

To customise the configuration, publish the config file:

```
php artisan vendor:publish --tag=phone-fieldtype-config
```

This will create `config/phone-fieldtype.php` where you can modify:

```
return [
    'primary_country' => env('PHONE_FIELDTYPE_PRIMARY_COUNTRY', 'AU'),
    'auto_fallback' => env('PHONE_FIELDTYPE_AUTO_FALLBACK', true),
];
```

### Configuration Options

[](#configuration-options)

- **`primary_country`**: The primary country code to use for validation (default: `AU`)
- **`auto_fallback`**: Enable automatic fallback detection if primary country fails (default: `true`)

Usage
-----

[](#usage)

### In Forms

[](#in-forms)

Add the field to your form blueprint:

```
tabs:
  main:
    sections:
      -
        fields:
          -
            field:
              type: phone_number_field
              display: Phone Number
              validate:
                - required
              placeholder: 'e.g. 0412 345 678, +61 412 345 678, +1 555 123 4567'
            handle: phone_number
```

### In Collections

[](#in-collections)

Add to any collection blueprint:

```
tabs:
  main:
    sections:
      -
        fields:
          -
            field:
              type: phone_number_field
              display: Phone Number
              validate:
                - required
              placeholder: 'e.g. 0412 345 678'
            handle: phone_number
```

### Configuration Options

[](#configuration-options-1)

The fieldtype supports standard text field options:

- `placeholder`: Placeholder text
- `default`: Default value
- `prepend`: Text to prepend
- `append`: Text to append

How It Works
------------

[](#how-it-works)

1. **User Input**: User enters phone number in various formats

    - `0412 345 678` (Australian mobile)
    - `(07) 3210 1234` (Australian landline)
    - `+61 412 345 678` (Australian international)
    - `+1 555 123 4567` (International)
2. **Validation**: Built-in validation with friendly error messages

    - Prioritises primary country format detection first (configurable, defaults to AU)
    - Falls back to international auto-detection (if enabled)
    - Shows clear error: "Please enter a valid phone number (e.g. 0412 345 678, (07) 3210 1234, +61 412 345 678, +1 555 123 4567)."
3. **Processing**: Converts to E.164 format for storage

    - All formats → E.164 (e.g. `+12345678901`)
    - Consistent data for integrations
    - Maintains original input validation
4. **Integration**: Perfect for external services

    - Zapier webhooks receive normalised format
    - HubSpot integration without format issues
    - API endpoints get consistent data structure

Example Data Flow
-----------------

[](#example-data-flow)

```
Input: 0412 345 678
↓ Validation (passes - detected as Australian)
↓ Processing
Output: +61412345678 (stored & sent to integrations)

```

Error Handling
--------------

[](#error-handling)

Invalid inputs show user-friendly messages:

```
Input: 123
Error: "Please enter a valid phone number (e.g. 0412 345 678, (07) 3210 1234, +61 412 345 678, +1 555 123 4567)."

```

Development
-----------

[](#development)

To contribute or modify:

1. Clone the repository
2. Install dependencies: `composer install`
3. Make changes to `src/Fieldtypes/PhoneNumberField.php`
4. Test in a Statamic project

Changelog
---------

[](#changelog)

### 1.0.0

[](#100)

- Initial release
- Phone number validation and E.164 formatting with Australia-first detection
- Support for Australian local and international formats
- Form and collection support
- Custom validation messages

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

Support
-------

[](#support)

- [GitHub Issues](https://github.com/visual1au/statamic-phone-fieldtype/issues)
- [Documentation](https://github.com/visual1au/statamic-phone-fieldtype)

Credits
-------

[](#credits)

Built with:

- [Statamic CMS](https://statamic.com)
- [Laravel-Phone](https://github.com/Propaganistas/Laravel-Phone)
- [libphonenumber](https://github.com/google/libphonenumber) (via Laravel-Phone)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance62

Regular maintenance activity

Popularity9

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

243d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8f6a7e7da0dd88a904d66e34e5c94c56a130e2c2e0aff287c5d16b27ddc34346?d=identicon)[Baumi-Dev](/maintainers/Baumi-Dev)

---

Tags

validationphonestatamicfieldtypeE164laravel-phone

### Embed Badge

![Health badge](/badges/visual1au-statamic-phone-fieldtype/health.svg)

```
[![Health](https://phpackages.com/badges/visual1au-statamic-phone-fieldtype/health.svg)](https://phpackages.com/packages/visual1au-statamic-phone-fieldtype)
```

###  Alternatives

[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M107](/packages/propaganistas-laravel-phone)[composer/semver

Version comparison library that offers utilities, version constraint parsing and validation.

3.3k489.6M672](/packages/composer-semver)[giggsey/libphonenumber-for-php

A library for parsing, formatting, storing and validating international phone numbers, a PHP Port of Google's libphonenumber.

5.0k148.7M416](/packages/giggsey-libphonenumber-for-php)[respect/validation

The most awesome validation engine ever created for PHP

5.9k37.4M383](/packages/respect-validation)[opis/json-schema

Json Schema Validator for PHP

64236.9M186](/packages/opis-json-schema)[giggsey/libphonenumber-for-php-lite

A lite version of giggsey/libphonenumber-for-php, which is a PHP Port of Google's libphonenumber

8412.9M47](/packages/giggsey-libphonenumber-for-php-lite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
