Home

Awesome

sfPersianTools

Persian tools for Symfony framework.

knpbundles.com

ohloh.com

Installation

Download PersianToolsBundle using composer

Add PersianToolsBundle in your composer.json

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

Now tell composer to download the bundle by running the command

$ php composer.phar update intuxicated/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