mhzarei / persian-tools-bundle
Persian Tools for Symfony 3 and 4
dev-master / 0.1.x-dev
2021-09-29 11:16 UTC
Requires
- php: >=5.3.3
- symfony/framework-bundle: ~3.0|~4.0
- twig/twig: >=1.5
This package is auto-updated.
Last update: 2025-03-01 00:43:37 UTC
README
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
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