Download the PHP package laxmidhar/desi-currency without Composer

On this page you can find all versions of the php package laxmidhar/desi-currency. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package desi-currency

Desi Currency - Indian Currency Helper for Laravel

Latest Version Total Downloads License Laravel Version

A comprehensive Laravel package for handling Indian currency formatting, conversions, and utilities. Format amounts in Lakhs, Crores, convert to words, parse shorthand notations (1L, 2.5Cr), and much more - all following Indian numbering standards.


โœจ Features


๐Ÿ“‹ Requirements


๐Ÿš€ Installation

Install via Composer:

The service provider will be automatically registered via Laravel's package auto-discovery.


๐Ÿ“– Usage

Facade Usage (Recommended)

Direct Class Usage

Dependency Injection


๐Ÿงฉ Available Methods

๐Ÿ’ฐ Core Formatting Methods

format(float $amount, bool $showSymbol = true): string

Format amount using Indian numbering system (โ‚น1,23,456.78).

Parameters:

Examples:

Key Features:


formatWhole(float $amount, bool $showSymbol = true): string

Format amount without decimal places.

Parameters:

Examples:

Use Cases:


formatAccounting(float $amount, bool $showSymbol = true): string

Format for accounting purposes (negative values in parentheses).

Parameters:

Examples:

Use Cases:


๐Ÿ”ค Words & Shorthand Conversion

toWords(float $amount, bool $showSymbol = true): string

Convert amount to readable words format (Lakh, Crore, K).

Parameters:

Examples:

Conversion Logic:


toShorthand(float $amount, bool $showSymbol = true): string

Convert to compact shorthand notation (1L, 2.5Cr, 500K).

Parameters:

Examples:

Use Cases:


toLakhs(float $amount, int $decimals = 2, bool $showSymbol = true): string

Always format in Lakhs, regardless of amount.

Parameters:

Examples:

Use Cases:


toCrores(float $amount, int $decimals = 2, bool $showSymbol = true): string

Always format in Crores, regardless of amount.

Parameters:

Examples:

Use Cases:


toIndianWords(float $amount): string

Convert amount to complete Indian words format.

Parameters:

Examples:

Use Cases:


๐Ÿ”„ Parsing & Conversion

parse(string $amount): float

Parse Indian currency notation back to numeric value.

Parameters:

Examples:

Supported Formats:

Use Cases:


๐Ÿ”ง Utility Methods

symbol(): string

Get the rupee currency symbol.

Examples:


splitRupeesPaise(float $amount): array

Split amount into rupees and paise components.

Parameters:

Examples:

Use Cases:


formatWithSuffix(float $amount, string $suffix = '', bool $showSymbol = true): string

Format amount with custom suffix.

Parameters:

Examples:

Use Cases:


isLakhsRange(float $amount): bool

Check if amount is in the Lakhs range (1L to 1Cr).

Parameters:

Examples:

Use Cases:


isCroresRange(float $amount): bool

Check if amount is in the Crores range (โ‰ฅ1Cr).

Parameters:

Examples:

Use Cases:


๐Ÿ’ก Practical Examples

E-commerce Product Display


Invoice Generation


Dashboard Statistics


Salary Package Display


User Input Processing


Financial Reports


Real Estate Listings


Blade Templates


๐ŸŽจ Blade Directives

Desi Currency provides convenient Blade directives for use in your Laravel views, making currency formatting clean and readable.

Quick Reference Table

Directive Purpose Input Example Output Example
@currency($amount) Standard format with symbol 123456.78 โ‚น1,23,456.78
@currencyWhole($amount) Format without decimals 123456.78 โ‚น1,23,457
@currencyPlain($amount) Format without symbol 123456.78 1,23,456.78
@currencyAccounting($amount) Accounting format -5000 (โ‚น5,000.00)
@inLakhs($amount) Always show in Lakhs 1500000 โ‚น15.00 Lakhs
@inCrores($amount) Always show in Crores 15000000 โ‚น1.50 Crores
@currencyShort($amount) Compact notation 1500000 โ‚น15L
@currencyWords($amount) Readable format 1500000 โ‚น15 Lakh
@currencySpell($amount) Full words 123456 One Lakh Twenty Three Thousand...
@rupeeSymbol Rupee symbol only - โ‚น
@inLakhRange($amount) Check Lakh range 500000 true/false
@inCroreRange($amount) Check Crore range 15000000 true/false

Available Directives

Standard Formatting

@currency($amount) - Format with Indian numbering and โ‚น symbol

@currencyWhole($amount) - Format without decimals

@currencyPlain($amount) - Format without currency symbol

@currencyAccounting($amount) - Accounting format (negatives in parentheses)


Indian Units (Lakh & Crore)

@inLakhs($amount) - Always display in Lakhs

@inCrores($amount) - Always display in Crores


Shorthand & Words

@currencyShort($amount) - Compact notation (L, Cr, K)

@currencyWords($amount) - Readable format (Lakh, Crore)

@currencySpell($amount) - Complete Indian words


Utilities

@rupeeSymbol - Just the rupee symbol


Conditional Directives

Use these to conditionally render based on amount range:

@inLakhRange($amount) - Check if amount is in Lakh range (1L - 1Cr)

@inCroreRange($amount) - Check if amount is in Crore range (โ‰ฅ1Cr)


Practical Blade Examples

Product Card

Invoice Template

Dashboard Widget

Financial Report

Salary Package Display


๐ŸŽฏ Best Practices

1. Consistent Display

Use the same format throughout your application for consistency:


2. Store as Numeric, Display as Formatted

Always store amounts as numeric values in database:


3. Handle User Input Properly

Parse user input before storing:


4. Use Appropriate Format for Context

Choose format based on where it's displayed:


5. Handle Negative Amounts

Always check for negative values:


๐Ÿงช Testing

Run the test suite:

Run tests with coverage:

Example Test Cases


๐Ÿ“Š Comparison with Other Solutions

Feature Desi Currency Manual Formatting Other Packages
Indian Numbering โœ… โŒ โš ๏ธ Limited
Lakh/Crore Support โœ… โŒ โŒ
Shorthand Parsing โœ… โŒ โŒ
Words Conversion โœ… โŒ โš ๏ธ English only
Zero Config โœ… N/A โŒ
Laravel Integration โœ… N/A โš ๏ธ Limited

๐Ÿ”’ Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.


๐Ÿค Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please ensure:


๐Ÿ“ Changelog

Please see CHANGELOG for recent changes.


๐Ÿ“„ License

This package is open-sourced software licensed under the MIT license.


๐Ÿ‘จโ€๐Ÿ’ป Author

Laxmidhar Maharana

Senior Laravel Developer โ€ข Open Source Contributor


โญ Show Your Support

If this package helped you, please give it a โญ๏ธ on GitHub!


๐Ÿ™ Acknowledgments

Special thanks to:


๐Ÿ“š Related Packages


๐Ÿ—บ๏ธ Roadmap

โœ… Completed

๐Ÿ”œ Upcoming


โ“ FAQ

Q: Can I use this for non-Indian currencies?
A: This package is specifically designed for Indian Rupee and Indian numbering system. For other currencies, consider using Laravel Money or similar packages.

Q: Does it handle GST calculations?
A: Not yet, but it's on the roadmap. Current version focuses on formatting and conversion.

Q: Can I customize the decimal places?
A: Yes, methods like toLakhs() and toCrores() accept a $decimals parameter.

Q: Does it work with Blade templates?
A: Yes! You can use the Currency facade directly in Blade templates as shown in the examples above.

Q: How do I handle very large amounts (Thousands of Crores)?
A: The package handles amounts up to PHP's float limit. For extremely large numbers, consider using BC Math functions.


Made with โค๏ธ for Indian Developers

Supporting Digital India โ€ข Made in India ๐Ÿ‡ฎ๐Ÿ‡ณ


All versions of desi-currency with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0|^8.1|^8.2|^8.3
illuminate/support Version ^9.0|^10.0|^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package laxmidhar/desi-currency contains the following files

Loading the files please wait ...