Download the PHP package manguithre/faker-madagascar without Composer

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

Faker Madagascar

Tests Latest Version on Packagist Total Downloads License: MIT PHP Version Laravel

Generate realistic Madagascar-specific test data for Laravel and PHP applications.

Faker Madagascar provides Malagasy names, structured geographical addresses, operator-aware mobile phone numbers and CIN-formatted values.

The package includes:

If you already know FakerPHP's fake() helper, you can start using this package immediately.

Generated data is intended for development, testing and database seeding. It does not represent real individuals or officially issued documents.

Features

Requirements

In a standard Laravel application, FakerPHP is usually already installed.

Installation

Install the package with Composer:

The service provider and the FakerMg facade alias are registered through Laravel package discovery. No manual registration is required.

The fakerMg() helper is available immediately after installation.

Quick start

After installing the package, use the fakerMg() helper anywhere in your Laravel application:

Usage styles

All usage styles resolve to the same Faker Madagascar service inside Laravel.

Using the fakerMg() helper

The helper is the recommended usage style:

The helper works in:

Using the facade

Laravel registers the facade alias automatically when package discovery is enabled.

Using dependency injection

Using FakerPHP

If FakerPHP is installed, the package registers a provider on Laravel's Faker generator. This allows you to mix standard FakerPHP data with Madagascar-specific data in the same call chain:

Note: The malagasy*() methods are available when Faker's generator is resolved through Laravel's container, for example with fake() or app(Faker\Generator::class). A generator created directly with Faker\Factory::create() does not automatically include this provider.

Example:

API reference

Method Description Return value
address() Generates a random hierarchical address. MalagasyAddress
address(region: ...) Generates an address inside a specific region. MalagasyAddress
addressInDistrict($region, $district) Generates an address inside a district. MalagasyAddress
addressInCommune($region, $district, $commune) Generates an address inside a commune. MalagasyAddress
region() Returns a random region. string
regions() Returns all region names. array
districts($region) Lists the districts of a region. array
district($region) Returns a random district in a region. string
communes($region, $district) Lists the communes of a district. array
commune($region, $district) Returns a random commune in a district. string
fokontany($region, $district, $commune) Returns a random fokontany in a commune. string
firstName() Generates a Malagasy first name. string
lastName() Generates a Malagasy last name. string
fullName() Generates a Malagasy full name. string
phoneNumber($operator = null) Generates a Malagasy mobile number. string
phonePrefixes() Returns the supported mobile prefixes. array
cin() Generates a 12-digit CIN-formatted value. string

Return types shown above should match the actual public API of the installed package version.

Generating addresses

Random address

The address object can be converted to a string:

It can also be converted to an array:

Force a region

The district, commune and fokontany are selected consistently from the specified region.

Region names are case-insensitive:

These values refer to the same region.

Force a district

Force a commune

Region names are resolved case-insensitively. District and commune names must match the names available in the dataset.

For example:

is valid, while this value may not be valid if exact matching is required:

Unknown regions, districts or communes throw:

Browse the geographical hierarchy

Address object

The address() method returns a structured address object.

Typical properties:

Convert the object to an array:

Convert the object to a formatted string:

The formatted string follows this structure:

Generating names

Names are generated from curated Malagasy name lists. They are intended to look natural for testing and development purposes.

Generated names are not guaranteed to correspond to real people.

Generating contact data

Phone numbers

You can optionally select an operator:

Supported prefixes:

The currently supported prefixes are:

Prefixes Operator
032, 037 Orange
033, 035 Airtel
034, 038 Telma / Yas
039 Bip

Phone prefixes were checked against the ARTEC national numbering plan, international numbering tables and available operator announcements.

The prefix dataset may need to be updated when the Malagasy numbering plan changes.

Phone numbers generated by this package are intended for testing and seeding. They should not be used to contact real people.

CIN values

The generated value contains 12 digits without separators.

CIN generation is intended for testing only. The package does not verify whether a CIN was officially issued or belongs to a real person.

Laravel factories and seeders

The package can be used directly inside Laravel factories:

Create 100 employees:

Important factory note

Generate values inside the factory definition so that every row receives fresh data.

Avoid calculating values once and reusing them:

The factory definition or a loop in a seeder should call fakerMg() for each record.

Seeder example

Validation rules

The package provides Laravel validation rules for Malagasy phone numbers and CIN values.

MalagasyPhoneNumber

The phone validation rule accepts formats such as:

It validates the Malagasy mobile format and supported operator prefixes.

MalagasyCin

The CIN validation rule accepts a 12-digit Malagasy CIN format.

Separators are tolerated and stripped before validation:

The rule validates the format only. It does not verify whether the CIN belongs to a real person or was officially issued.

Artisan command

The package includes an Artisan command for previewing generated data.

Generate random addresses

Generate random persons

Generate contact data

Export to JSON

Export to CSV

Export files are written to the system temporary directory. The command displays the generated file path after the export is completed.

Configuration

Publish the configuration file:

The configuration file is:

Restrict random generation to selected regions

With this configuration, random address generation only uses the selected regions:

Forcing an inactive region throws an exception:

Region names in the configuration are case-insensitive:

Using the package outside Laravel

The core service can also be used in a plain PHP application:

When Laravel is not available, the helper falls back to a standalone FakerMadagascar instance.

You can also instantiate the service directly:

Testing the package in a fresh Laravel application

Create a fresh Laravel application:

If you are testing a local checkout of the package, configure the local Composer repository:

Install the local development version:

Then add a test route in routes/web.php:

Start the development server:

Open the displayed local URL and visit:

Testing

Run the test suite with:

You can also run the package tests directly if the project provides a PHPUnit configuration:

Data sources

The package includes the following geographical data:

The geographical dataset is sourced from julkwel/madagascar-map, released under the MIT License.

After updating the source geography files, rebuild the generated dataset with:

Phone prefixes are maintained using information from the ARTEC national numbering plan and other available Malagasy operator and numbering references.

Contributing

Contributions, corrections and improvements are welcome.

Before opening a pull request:

When contributing geographical data, please include the source and explain the reason for the change.

For new public methods, include:

Versioning

This package follows semantic versioning whenever possible.

Breaking changes may require a major version update. Check the changelog and release notes before upgrading between major versions.

Credits

License

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

See the LICENSE file for more information.


All versions of faker-madagascar with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^11.0|^12.0|^13.0
illuminate/validation Version ^11.0|^12.0|^13.0
illuminate/console Version ^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 manguithre/faker-madagascar contains the following files

Loading the files please wait ...