PHPackages                             techecosystem/parsify-php - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. techecosystem/parsify-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

techecosystem/parsify-php
=========================

A PHP library for Persian text conversion, including number translation, diacritics removal, and normalization with a fluent API.

v1.0.0(1y ago)3521MITPHPPHP &gt;=8.2

Since Jan 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/techecosystem/parsify-php)[ Packagist](https://packagist.org/packages/techecosystem/parsify-php)[ Docs](https://github.com/techecosystem/parsify-php)[ RSS](/packages/techecosystem-parsify-php/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Persian Converter Library
=========================

[](#persian-converter-library)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Latest Version on Packagist](https://camo.githubusercontent.com/a7f6048596f8156e9e696a74cfa5046d7639a5653ef9bdbe72b45231b368c061/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7465636865636f73797374656d2f706172736966792d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/techecosystem/parsify-php)[![Total Downloads](https://camo.githubusercontent.com/7064f65d5bd657c93585e577740295189d95430999d1d9a776df9d8294647711/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7465636865636f73797374656d2f706172736966792d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/techecosystem/parsify-php)

The **Persian Converter Library** is a powerful tool designed to handle Persian text conversion, including removing diacritics, converting numbers between English and Persian, and other text normalizations. This library provides an easy-to-use interface for developers to work with Persian text more effectively.

Features
--------

[](#features)

- Convert English numbers to Persian and vice versa.
- Remove diacritics from Persian text.
- Highly customizable through a fluent builder pattern.
- Lightweight and efficient.

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

[](#installation)

To install the library, you can use [Composer](https://getcomposer.org/):

```
composer require techecosystem/parsify-php
```

API Documentation
-----------------

[](#api-documentation)

### `PersianConverterBuilder Class`

[](#persianconverterbuilder-class)

The `PersianConverterBuilder` class provides a fluent interface to create a `PersianConverter` with customizable strategies for text normalization and number conversion.

#### Methods

[](#methods)

- **`static create(): self`**

    - Creates and returns a new instance of the builder.
    - **Example:**

        ```
        $builder = PersianConverterBuilder::create();
        ```
- **`withNumberConversion(bool $keepEnglishNumbers = false): self`**

    - Enables number conversion. By default, converts English and Arabic numbers to Persian numbers.
    - #### **Parameters:**

        [](#parameters)

        - `bool $keepEnglishNumbers` (default: `false`): Whether to keep English numbers.
        - If `$keepEnglishNumbers` is `true`, only Arabic numbers are converted.
    - **Example:**

        ```
        $builder->withNumberConversion(true);
        ```
- **`withTextNormalization(bool $keepPersianDiacritic = true): self`**

    - Enables text normalization. Optionally keeps Persian diacritics.
    - #### **Parameters:**

        [](#parameters-1)

        - `bool $keepPersianDiacritic` (default: `true`): Whether to keep Persian diacritics.
    - **Example:**

        ```
        $builder->withTextNormalization(false);
        ```
- **`build(): PersianConverter`**

    - Builds and returns a `PersianConverter` instance with the configured strategies.
    - **Throws:**

        - `MissingStrategyException` If no strategies are enabled, i.e., both text normalization and number conversion are disabled.
    - **Example:**

        ```
        $converter = $builder->build();
        ```

### `PersianConverter Class`

[](#persianconverter-class)

The `PersianConverter` class applies various conversion strategies to normalize Persian text and convert numbers.

#### **Methods**

[](#methods-1)

- **`static createDefault(): self`**

    - Creates a default `PersianConverter` with text normalization and Persian number conversion enabled.
    - **Example:**

        ```
        $converter = PersianConverter::createDefault();
        ```
- **`convert(string $input): string`**

    - Applies all strategies to the input string and returns the converted text.
    - **Throws:**

        - `TextConversionException` on conversion failure.
    - **Example:**

        ```
        $convertedText = $converter->convert("متن فارسی 123");
        ```

### `PersianTextService Class`

[](#persiantextservice-class)

The `PersianTextService` class provides utility methods for text normalization using `PersianConverter` with various configurations.

#### Methods

[](#methods-2)

- **`static normalize(string $input): string`**
    Normalizes the text with default settings (text normalization and Persian number conversion).

    - **Example:**

        ```
        $normalizedText = PersianTextService::normalize("متن فارسی 123");
        ```
- **`static normalizeTextWithEnglishNumbers(string $input): string`**

    - Normalizes the text while keeping English numbers.
    - **Example:**

        ```
        $normalizedText = PersianTextService::normalizeTextWithEnglishNumbers("متن فارسی 123");
        ```
- **`static normalizeTextWithoutNumbers(string $input): string`**

    - Normalizes the text without converting numbers.
    - **Example:**

        ```
        $normalizedText = PersianTextService::normalizeTextWithoutNumbers("متن فارسی 123");
        ```

**Examples**
------------

[](#examples)

1. Simple Text Normalization

    ```
    echo PersianTextService::normalize("𞸮ﻼم 123 يوﺱ𞺰");
    // Outputs: "سلام ۱۲۳ یوسف"
    ```
2. Normalization with English Numbers

    ```
    echo PersianTextService::normalizeTextWithEnglishNumbers("𞸮ﻼم 123 يوﺱ𞺰");
    // Outputs: "سلام 123 یوسف"
    ```
3. Normalization without Number Conversion

    ```
    echo PersianTextService::normalizeTextWithoutNumbers("𞸮ﻼم 123 يوﺱ𞺰");
    // Outputs: "سلام 123 یوسف"
    ```
4. Custom Converter: Combining Multiple Conversions

    The library allows chaining multiple conversion rules in one go:

    ```
    $converter = PersianConverterBuilder::create()
        ->withTextNormalization(false)
        ->withNumberConversion()
        ->build();
    echo $converter->convert("𞸮ﻼم 123 يوﺱ𞺰");
    // Outputs: "سلام ۱۲۳ یوسف"
    ```
5. Removing Diacritics

    You can also remove diacritics from Persian text using the following approach:

    ```
    $converter = PersianConverterBuilder::create()
        ->withTextNormalization(keepPersianDiacritic: false)
        ->build();

    $input = "حَتماً";
    echo $converter->convert($input);
    // Outputs: حتما
    ```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

License
-------

[](#license)

This library is open-source software licensed under the [MIT license](LICENSE).

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

538d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9de940ce465f796c0b34447e212ae047bf3bc3cb805e2a1ebb62f7223a5740de?d=identicon)[griffin0t03h](/maintainers/griffin0t03h)

---

Top Contributors

[![SinaMoradi9571](https://avatars.githubusercontent.com/u/194265866?v=4)](https://github.com/SinaMoradi9571 "SinaMoradi9571 (2 commits)")

---

Tags

persianpersian-languagephpphp-librarytext-conversiontext-normalizationtext-utilitiesphppersianfluent-apiPHP Librarytext utilitiestext conversionnumber translationdiacritics removaltext normalization

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/techecosystem-parsify-php/health.svg)

```
[![Health](https://phpackages.com/badges/techecosystem-parsify-php/health.svg)](https://phpackages.com/packages/techecosystem-parsify-php)
```

###  Alternatives

[niiknow/bayes

a machine learning lib

7056.3k](/packages/niiknow-bayes)[amirezaeb/heroqr

A Powerful QR Code Management Library For PHP

9813.9k](/packages/amirezaeb-heroqr)[ramazancetinkaya/byte-formatter

A modern PHP library for formatting and parsing byte values with precision and flexibility.

145.0k](/packages/ramazancetinkaya-byte-formatter)

PHPackages © 2026

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