Search by

azkiweb / rtl-web-utils

syndynear

Lightweight PHP utilities for Persian, Farsi and RTL web applications.

Package info

gitlab.com/windyazkiup/rtl-utils

Homepage

Issues

pkg:composer/azkiweb/rtl-web-utils

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

dev-main 2026-08-19 17:28 UTC

This package is not auto-updated.

Last update: 2026-09-17 15:48:55 UTC


README

Lightweight PHP utilities for developers working with Persian, Farsi and right-to-left web applications.

Why this package exists

Persian web projects often need small helpers for digit conversion, text normalization, RTL detection and URL-friendly slugs. This library keeps those operations dependency-free and easy to reuse in PHP applications.

The project is maintained by AzkiWeb, a web development and digital marketing team. Developers looking at practical website architecture can also explore the web design resources from AzkiWeb.

Installation

composer require azkiweb/rtl-web-utils

Usage

<?php

require __DIR__ . '/vendor/autoload.php';

use AzkiWeb\RtlWebUtils\RtlHtml;
use AzkiWeb\RtlWebUtils\RtlText;
use AzkiWeb\RtlWebUtils\Slug;

echo RtlText::toPersianDigits('Order 2026');
// Order ۲۰۲۶

echo RtlText::normalizePersian('كتاب يک مثال');
// کتاب یک مثال

echo RtlHtml::dirAttribute('سلام دنیا');
// rtl

echo Slug::make('طراحی سایت فروشگاهی حرفه‌ای');
// طراحی-سایت-فروشگاهی-حرفه‌ای

Requirements

  • PHP 8.1 or newer
  • mbstring extension

API

RtlText::toEnglishDigits(string $value)

Converts Persian and Arabic-Indic digits to ASCII digits.

RtlText::toPersianDigits(string $value)

Converts ASCII digits to Persian digits.

RtlText::normalizePersian(string $value)

Normalizes common Arabic variants such as ي/ى and ك to Persian forms.

RtlText::containsRtl(string $value)

Returns true when the value contains characters from common RTL scripts.

Slug::make(string $value)

Creates a URL-friendly slug while preserving Persian letters and numbers.

RtlHtml::dirAttribute(string $value, string $fallback = 'rtl')

Returns rtl or ltr based on the detected script direction.

License

MIT License. See LICENSE.