Download the PHP package nanayawkumi/gh-phone-validator without Composer

On this page you can find all versions of the php package nanayawkumi/gh-phone-validator. 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 gh-phone-validator

Gh Phone Validator

A Laravel validation rule and helper package for validating and normalizing Ghana phone numbers.

Installation

Install the package via Composer:

The package will automatically register its service provider if you're using Laravel's package auto-discovery.

Requirements

Usage

Validation Rule

You can use the gh_phone validation rule in your form requests or controllers:

Or use the rule class directly:

Normalize Phone Numbers

The normalize() method converts various phone number formats to a standard 10-digit format (starting with 0):

Detect Network

The network() method identifies the network provider for a given phone number and returns a Network enum:

For backward compatibility, you can also use networkInfo() to get the array format:

Validate Phone Numbers

The validate() method checks if a phone number is valid (10 digits and starts with a valid network prefix):

Format Phone Numbers

The package provides several formatting methods to display phone numbers in different formats:

Raw Local Format

The formatRaw() method returns the phone number in raw local format (10 digits starting with 0):

National Format

The formatNational() method formats the phone number with spaces for readability:

International Format

The formatInternational() method formats the phone number in international readable format:

E.164 Format

The formatE164() method formats the phone number in E.164 international format:

Common Use Cases

UI Display

Format phone numbers for display in your user interface:

SMS / Telco APIs

Format phone numbers in E.164 format for SMS gateways and telco APIs:

Eloquent Cast

This package provides an Eloquent cast for Ghana phone numbers.

Basic Usage

Behavior

Example:

Cast Storage Customization

You can control how phone numbers are stored in the database.

Store as Raw Local Format (default)

Phone numbers are stored in raw local format (e.g., 0241234567) by default.

Store as E.164 Format

Phone numbers are stored in E.164 international format (e.g., +233241234567).

Notes

Example:

Network Enum

The package provides a strongly-typed Network enum for working with network providers.

Using the Network Enum

From Eloquent Cast

When using the Eloquent cast, the network() method returns a Network enum:

Available Methods

The Network enum provides the following methods:

Example:

Supported Networks

The package recognizes the following network providers:

Configuration

Publish the configuration file to customize network settings:

This will create a config/gh-phone-validator.php file where you can modify network codes and names.

Strict Mode

Strict mode controls whether the package accepts phone numbers with unknown network prefixes:

Example:

License

This package is open-sourced software licensed under the MIT license.

Author

Samuel Kumi-Buabeng


All versions of gh-phone-validator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/validation Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.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 nanayawkumi/gh-phone-validator contains the following files

Loading the files please wait ...