PHPackages                             iamvimukthi/loancalculator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. iamvimukthi/loancalculator

ActivePackage[Utility &amp; Helpers](/categories/utility)

iamvimukthi/loancalculator
==========================

A simple Laravel package for calculating loans, including EMI, interest, and total payments. Perfect for financial apps with easy integration and customizable options.

1.0.0(1y ago)07MITPHP

Since Dec 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/IamVimukthi/loan-calculator)[ Packagist](https://packagist.org/packages/iamvimukthi/loancalculator)[ RSS](/packages/iamvimukthi-loancalculator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Loan Calculator
===============

[](#loan-calculator)

A Laravel package for calculating loan details, including **EMI (Equated Monthly Installment)**, **Total Cost**, **Total Interest**, and generating a detailed **Payment Schedule**. This package is ideal for financial applications requiring loan calculations.

Features
--------

[](#features)

- Calculate **EMI**, **Total Cost**, and **Total Interest** for a loan.
- Generate a **Payment Schedule** with a month-by-month breakdown of payments.
- Accepts flexible loan terms in both **years** and **months**.
- Easy integration with Laravel applications.

---

Installation
------------

[](#installation)

### Step 1: Install via Composer

[](#step-1-install-via-composer)

Run the installation command:

```
composer require iamvimukthi/loancalculator:1.0.0
```

### Step 2: (Optional) Publish Configuration

[](#step-2-optional-publish-configuration)

To publish the configuration file (if required):

```
php artisan vendor:publish --provider="Iamvimukthi\Loancalculator\LoanCalculatorService"
```

---

Usage
-----

[](#usage)

### 1. **Calculate Loan Details**

[](#1-calculate-loan-details)

Use the `calculateLoanDetails` method to calculate the EMI, total cost, and total interest for a loan.

```

use Iamvimukthi\Loancalculator\LoanCalculator;

$loanAmount = 500000;  // Principal amount
$annualInterestRate = 5;  // Annual interest rate (percentage)
$loanTermYears = 5;  // Loan term in years
$loanTermMonths = 6;  // Additional months

$loanDetails = LoanCalculator::calculateLoanDetails($loanAmount, $annualInterestRate, $loanTermYears, $loanTermMonths);

echo "Monthly EMI: " . number_format($loanDetails['EMI'], 2) . "\n";
echo "Total Cost of Loan: " . number_format($loanDetails['TotalCost'], 2) . "\n";
echo "Total Interest: " . number_format($loanDetails['TotalInterest'], 2) . "\n";

```

**Output Example:**

```

Monthly EMI: 8,680.78
Total Cost of Loan: 572,931.50
Total Interest: 72,931.50

```

### 2. **Generate Payment Schedule**

[](#2-generate-payment-schedule)

Use the `generatePaymentSchedule` method to create a detailed payment schedule for the loan.

```

$schedule = LoanCalculator::generatePaymentSchedule($loanAmount, $annualInterestRate, $loanTermYears, $loanTermMonths);

foreach ($schedule as $payment) {
    echo "Month-Year: {$payment['MonthYear']}, Principal: " . number_format($payment['PrincipalPayment'], 2) . ", Interest: " . number_format($payment['InterestPayment'], 2) . ", Total: " . number_format($payment['TotalPayment'], 2) . ", Balance: " . number_format($payment['Balance'], 2) . "\n";
}

```

**Output Example:**

```

Month-Year: Dec-2024, Principal: 6,597.45, Interest: 2,083.33, Total: 8,680.78, Balance: 493,402.55
Month-Year: Jan-2025, Principal: 6,624.94, Interest: 2,055.84, Total: 8,680.78, Balance: 486,777.62
...

```

---

Methods
-------

[](#methods)

### `calculateLoanDetails($loanAmount, $annualInterestRate, $loanTermYears, $loanTermMonths = 0)`

[](#calculateloandetailsloanamount-annualinterestrate-loantermyears-loantermmonths--0)

- **Description**: Calculates EMI, total cost, and total interest for the given loan.
- **Parameters**:
    - `$loanAmount` (float): Principal loan amount.
    - `$annualInterestRate` (float): Annual interest rate (percentage).
    - `$loanTermYears` (int): Loan term in years.
    - `$loanTermMonths` (int): Additional months to add to the loan term (default: 0).
- **Returns**: Array containing:
    - `'EMI'`: Monthly installment.
    - `'TotalCost'`: Total loan cost (principal + interest).
    - `'TotalInterest'`: Total interest paid.

### `generatePaymentSchedule($loanAmount, $annualInterestRate, $loanTermYears, $loanTermMonths = 0)`

[](#generatepaymentscheduleloanamount-annualinterestrate-loantermyears-loantermmonths--0)

- **Description**: Generates a detailed payment schedule for the loan.
- **Parameters**:
    - `$loanAmount` (float): Principal loan amount.
    - `$annualInterestRate` (float): Annual interest rate (percentage).
    - `$loanTermYears` (int): Loan term in years.
    - `$loanTermMonths` (int): Additional months to add to the loan term (default: 0).
- **Returns**: Array containing:
    - `'MonthYear'`: Month and year of the payment.
    - `'PrincipalPayment'`: Principal portion of the payment.
    - `'InterestPayment'`: Interest portion of the payment.
    - `'TotalPayment'`: Total payment (EMI).
    - `'Balance'`: Remaining loan balance.

---

Testing
-------

[](#testing)

Run unit tests for the package using PHPUnit to ensure calculations are accurate.

```
php artisan test
```

**Example test case:**

```

use Iamvimukthi\Loancalculator\LoanCalculator;

class LoanCalculatorTest extends TestCase
{
    public function testCalculateLoanDetails()
    {
        $loanDetails = LoanCalculator::calculateLoanDetails(500000, 5, 5, 6);

        $this->assertEquals(9432.26, $loanDetails['EMI']);
        $this->assertEquals(566136.45, $loanDetails['TotalCost']);
        $this->assertEquals(66136.45, $loanDetails['TotalInterest']);
    }
}

```

---

License
-------

[](#license)

This package is licensed under the [MIT License](LICENSE).

Contributing
------------

[](#contributing)

Contributions are welcome! Please follow these steps to contribute:

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

---

Contact
-------

[](#contact)

For any issues or suggestions, please create an issue on the [GitHub Issues](https://github.com/IamVimukthi/loan-calculator/issues) page.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance40

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

515d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a6bd0ecf4ff9856d5408db3263702405345dacc0032144971c7228bb6dbeae4d?d=identicon)[IamVimukthi](/maintainers/IamVimukthi)

---

Top Contributors

[![IamVimukthi](https://avatars.githubusercontent.com/u/34433127?v=4)](https://github.com/IamVimukthi "IamVimukthi (8 commits)")

### Embed Badge

![Health badge](/badges/iamvimukthi-loancalculator/health.svg)

```
[![Health](https://phpackages.com/badges/iamvimukthi-loancalculator/health.svg)](https://phpackages.com/packages/iamvimukthi-loancalculator)
```

###  Alternatives

[teguh02/indonesia-territory-forms

Display a Indonesia Territory Select Form For Filament Within the Zip-Code Without Any Seeder Needed

161.1k](/packages/teguh02-indonesia-territory-forms)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
