Skip to content

MHZarei/sfPersianToolsBundle

 
 

Repository files navigation

sfPersianTools

Persian tools for Symfony framework.

Installation

Download PersianToolsBundle using composer

Add PersianToolsBundle in your composer.json

{
    "require": {
        "mhzarei/persian-tools-bundle": "dev-master"
    }
}

Now tell composer to download the bundle by running the command

$ php composer.phar update mhzarei/persian-tools-bundle

Enable the bundle

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Intuxicated\PersianToolsBundle\PersianToolsBundle(),
    );
}

Twig Filters

{{ '1364509205'|pdate }} {# result: 1392-01-09 #}
{{ '1364509205'|pdate('Y-m-d H:i:s') }} {# result: 1392-01-09 02:50:05 #}

{{ '123456789'|pnumber  }} {# result: ۱۲۳۴۵۶۷۸۹ #}

{{ 'ملك عربي'|pletter }} {# result: 'ملک عربی'#}

Twig Functions

pdate

pstrftime

pmktime

pcheckdate

pgetdate

DayOfYear return past days of the year

isKabise return true if year is intercalary

pnumber convert English/Arabic numbers to Persian numbers

pletter convert Arabic letters to Persian Letters

Controller Functions

You can use all twig functions in controller. just simply load persian_tools service :

$pt = $this->get('persian_tools');

// example
echo $pt->pnumber('123456');

License

https://github.com/intuxicated/sfPersianToolsBundle/blob/master/LICENSE

About

Persian Tools for Symfony 4

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%