PHPackages                             yassine-as/laravel-multi-currency - 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. yassine-as/laravel-multi-currency

ActiveLibrary

yassine-as/laravel-multi-currency
=================================

Laravel package for multi-currency support with automatic conversion

v1.0.0(11mo ago)03MITPHPPHP ^8.0

Since May 24Pushed 11mo agoCompare

[ Source](https://github.com/Asyassin10/laravel-multi-currency)[ Packagist](https://packagist.org/packages/yassine-as/laravel-multi-currency)[ RSS](/packages/yassine-as-laravel-multi-currency/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Laravel Multi-Currency Package
==============================

[](#laravel-multi-currency-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/37515428fac3216a197ea1df80072dc17d404a41bfb9ccadeae6ac45167da409/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f79617373696e652d61732f6c61726176656c2d6d756c74692d63757272656e63792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yassine-as/laravel-multi-currency)[![Total Downloads](https://camo.githubusercontent.com/cc91c6c04593d0654101ab8a303d503d5864228fa63cb04916f154ce9dcab23c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f79617373696e652d61732f6c61726176656c2d6d756c74692d63757272656e63792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yassine-as/laravel-multi-currency)[![License](https://camo.githubusercontent.com/dabc519ea2ce2bf2cc9e8f6a140cc80c3992be5497b74479a1220e13af59268f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f79617373696e652d61732f6c61726176656c2d6d756c74692d63757272656e63792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yassine-as/laravel-multi-currency)

A comprehensive Laravel package for multi-currency support with automatic conversion, IP-based currency detection, caching, and seamless integration.

✨ Features
----------

[](#-features)

- 🌍 **Automatic Currency Detection** - Detects user's currency based on IP geolocation
- 💱 **Real-time Exchange Rates** - Fetches rates from multiple providers (ExchangeRate-API, CurrencyAPI)
- ⚡ **Smart Caching** - Database + memory caching to optimize performance
- 🎛️ **Manual Currency Switching** - User-friendly dropdown with AJAX support
- 🍪 **Session &amp; Cookie Support** - Remembers user preferences
- 🎨 **Blade Directives** - Easy integration with `@currency()` and `@currencySymbol`
- 🛡️ **Middleware Support** - Automatic currency detection per request
- 🔧 **Artisan Commands** - Update exchange rates via command line
- 📱 **Responsive UI** - Ready-to-use currency switcher component

🚀 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require yassine-as/laravel-multi-currency
```

### Publish Configuration &amp; Migrations

[](#publish-configuration--migrations)

```
# Publish config file
php artisan vendor:publish --provider="YassineAs\MultiCurrency\MultiCurrencyServiceProvider" --tag="config"

# Publish migrations
php artisan vendor:publish --provider="YassineAs\MultiCurrency\MultiCurrencyServiceProvider" --tag="migrations"

# Publish views (optional)
php artisan vendor:publish --provider="YassineAs\MultiCurrency\MultiCurrencyServiceProvider" --tag="views"
```

### Run Migrations

[](#run-migrations)

```
php artisan migrate
```

⚙️ Configuration
----------------

[](#️-configuration)

Add these variables to your `.env` file:

```
# Base currency for your products
DEFAULT_CURRENCY=USD

# Exchange rate provider (exchangerate-api or currencyapi)
EXCHANGE_RATE_PROVIDER=exchangerate-api

# API Keys (get free keys from providers)
EXCHANGE_RATE_API_KEY=your_exchangerate_api_key
CURRENCY_API_KEY=your_currency_api_key

# Auto-detect currency based on user's IP
AUTO_DETECT_CURRENCY=true

# Cache duration in seconds (3600 = 1 hour)
CURRENCY_CACHE_DURATION=3600
```

### Get Free API Keys

[](#get-free-api-keys)

**ExchangeRate-API (Recommended):**

1. Visit [exchangerate-api.com](https://exchangerate-api.com)
2. Sign up for free (1,500 requests/month)
3. Copy your API key to `EXCHANGE_RATE_API_KEY`

**CurrencyAPI (Alternative):**

1. Visit [currencyapi.com](https://currencyapi.com)
2. Sign up for free (300 requests/month)
3. Copy your API key to `CURRENCY_API_KEY`

📖 Usage
-------

[](#-usage)

### 1. In Blade Templates

[](#1-in-blade-templates)

```
{{-- Display price with current currency --}}
Price: @currency($product->price)

{{-- Display just the currency symbol --}}
@currencySymbol

{{-- Include the currency switcher dropdown --}}
@include('multi-currency::currency-switcher')

{{-- Convert specific amount --}}
Converted: @currency(100, 'EUR')
```

### 2. In Controllers

[](#2-in-controllers)

```
