Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Iso Currencies

Iso Currencies Laravel Package

moneyphp/iso-currencies

Up-to-date ISO 4217 currency list for MoneyPHP, sourced from the official ISO 4217 Maintenance Agency (currency-iso.org). Includes tooling to fetch and update the currency dataset via Composer for use with moneyphp/money.

View on GitHub
Deep Wiki
Context7

Provides up-to-date list of ISO 4217 currencies

Frequently asked questions about Iso Currencies
How do I integrate this package with Laravel’s service container for dependency injection?
Bind the `CurrencyRepository` as a singleton in a service provider using `$this->app->singleton(CurrencyRepository::class, fn($app) => new CurrencyRepository());`. Then inject it into controllers, services, or commands via constructor injection. This ensures reusable, testable access to ISO 4217 currency data across your application.
Can I use this package without MoneyPHP (e.g., for standalone validation or reporting)?
While the package is optimized for MoneyPHP, you can use it standalone by accessing the `CurrencyRepository` directly. For example, fetch all active currencies with `$repository->getAllActiveCurrencies()` and validate user input against ISO 4217 codes. However, historical flagging (e.g., BGN post-2026) is tied to MoneyPHP’s use case, so abstraction may be needed for non-MoneyPHP workflows.
What Laravel versions does this package support, and are there any PHP version requirements?
The package has no explicit Laravel version dependency but requires PHP 8.0+. It’s framework-agnostic, so it works with Laravel 9+ or 10+ out of the box. Test compatibility by checking the `moneyphp/money` package’s Laravel support, as this package extends its functionality. No Laravel-specific features are required for basic usage.
How do I automate currency updates in Laravel (e.g., via Artisan or task scheduling)?
Extend the Composer `fetch-update` command into a custom Artisan command. For example, create a `CurrencyUpdateCommand` that runs `composer fetch-update` and caches the result in Laravel’s config or database. Schedule it via `schedule:run` in your `app/Console/Kernel.php` (e.g., `@daily`). This ensures your app always uses the latest ISO 4217 data.
Does this package handle historical currencies (e.g., BGN after 2026) for compliance or legacy systems?
Yes. The package flags historical currencies (e.g., BGN post-2026) via the `isActive()` method. Use this to validate transactions or reject deprecated currencies in real-time. For example: `if (!$currency->isActive()) throw new InvalidCurrencyException(...);`. This is critical for legacy systems or regulatory compliance in financial applications.
What’s the best way to test this package in Laravel (e.g., unit or feature tests)?
Mock the `CurrencyRepository` in tests by binding a fake implementation in your `phpunit.xml` or test setup. For example, use Laravel’s `partialMock` to override `getCurrency()` and return predefined `Currency` objects. Test edge cases like deprecated currencies or invalid codes. Since the data is immutable, focus on validation logic rather than data integrity.
Are there performance concerns with loading ISO 4217 data in production?
No. The package loads currency data once during initialization (lazy-loaded by default) and caches it in memory. Runtime overhead is negligible—ideal for high-traffic Laravel apps like payment gateways. For further optimization, cache the data in Laravel’s config or Redis after the first update, reducing I/O operations.
How do I handle cases where I need runtime currency updates (e.g., real-time additions)?
This package provides static data, so it’s not suited for dynamic updates. Mitigate this by layering a cache (e.g., Redis) on top of the static data. Use the package as a baseline and allow runtime overrides via your cache layer. For example, store custom currencies in Redis and merge them with the ISO 4217 list at runtime.
What alternatives exist for ISO 4217 currency data in Laravel, and when should I choose this package?
Alternatives include hardcoded arrays, third-party APIs (e.g., `league/currency`), or custom databases. Choose this package if you need **official ISO 4217 compliance**, **automated updates**, and **MoneyPHP integration**. Avoid it if you require dynamic currency management or aren’t using MoneyPHP, as alternatives like `league/currency` may offer more flexibility.
How do I validate user-input currency codes in Laravel forms or API requests using this package?
Use Laravel’s validation rules with the package’s data. For forms, add `Rule::in($currencyRepository->getAllActiveCurrencyCodes())` to your `FormRequest`. For APIs, inject the `CurrencyRepository` into your `ValidatedRequest` and validate dynamically. Example: `$request->validate(['currency' => ['required', 'string', fn($attr, $value, $fail) => $this->currencyRepository->getCurrency($value) ?: $fail('Invalid currency code.')]])`.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
symfony/ai-symfony-mate-extension
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata