Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from florianv/swap3
Swap 3.0
- Loading branch information
Showing
16 changed files
with
743 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
; This file is for unifying the coding style for different editors and IDEs. | ||
; More information at http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_size = 4 | ||
indent_style = space | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
* text=auto | ||
|
||
/doc export-ignore | ||
/tests export-ignore | ||
.editorconfig export-ignore | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
.scrutinizer.yml export-ignore | ||
.styleci.yml export-ignore | ||
.travis.yml export-ignore | ||
phpunit.xml export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
filter: | ||
excluded_paths: [tests/*] | ||
|
||
checks: | ||
php: | ||
remove_extra_empty_lines: true | ||
remove_php_closing_tag: true | ||
remove_trailing_whitespace: true | ||
fix_use_statements: | ||
remove_unused: true | ||
preserve_multiple: false | ||
preserve_blanklines: true | ||
order_alphabetically: true | ||
fix_php_opening_tag: true | ||
fix_linefeed: true | ||
fix_line_ending: true | ||
fix_identation_4spaces: true | ||
fix_doc_comments: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
preset: symfony | ||
|
||
finder: | ||
path: | ||
- "src" | ||
- "tests" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,85 @@ | ||
# Laravel Swap | ||
<img src="https://github.com/florianv/swap/blob/master/doc/logo.png" width="200px" align="left"/> | ||
> Currency exchange rates library for Laravel | ||
[![Build status][travis-image]][travis-url] | ||
[![Version][version-image]][version-url] | ||
[![Downloads][downloads-image]][downloads-url] | ||
[![Build status](http://img.shields.io/travis/florianv/laravel-swap.svg?style=flat-square)](https://travis-ci.org/florianv/laravel-swap) | ||
[![Total Downloads](https://img.shields.io/packagist/dt/florianv/laravel-swap.svg?style=flat-square)](https://packagist.org/packages/florianv/laravel-swap) | ||
[![Scrutinizer](https://img.shields.io/scrutinizer/g/florianv/laravel-swap.svg?style=flat-square)](https://scrutinizer-ci.com/g/florianv/laravel-swap) | ||
[![Version](http://img.shields.io/packagist/v/florianv/laravel-swap.svg?style=flat-square)](https://packagist.org/packages/florianv/laravel-swap) | ||
|
||
> Integrates [Swap](https://github.com/florianv/swap) with Laravel | ||
**Swap** allows you to retrieve currency exchange rates from various services such as [Fixer](http://fixer.io) or [Yahoo](https://finance.yahoo.com/) and optionally cache the results. | ||
|
||
## Installation | ||
<br /><br /> | ||
|
||
Install the package via [Composer](https://getcomposer.org): | ||
## QuickStart | ||
|
||
1) Install via Composer: | ||
|
||
```bash | ||
$ composer require florianv/laravel-swap | ||
$ composer require florianv/laravel-swap php-http/message php-http/guzzle6-adapter | ||
``` | ||
|
||
## Configuration | ||
|
||
Register the service provider and the facade in your configuration: | ||
2) Configure the Service Provider and alias: | ||
|
||
```php | ||
// config/app.php | ||
'providers' => [ | ||
Florianv\LaravelSwap\SwapServiceProvider::class | ||
Swap\Laravel\SwapServiceProvider::class | ||
], | ||
|
||
'aliases' => [ | ||
'Swap' => Florianv\LaravelSwap\Facades\Swap::class | ||
'Swap' => Swap\Laravel\Facades\Swap::class | ||
] | ||
``` | ||
|
||
Publish Swap's configuration: | ||
3) Publish the Package configuration | ||
|
||
```bash | ||
$ php artisan vendor:publish | ||
$ php artisan vendor:publish --provider="Swap\Laravel\SwapServiceProvider" | ||
``` | ||
|
||
By default, `Swap` is configured to use the `FileGetContentsHttpAdapter`, the `YahooFinanceProvider` provider and don't use a cache. | ||
4) Start using it! | ||
|
||
For more informations about all possibilities including Laravel Cache integration, read the comments in the | ||
[configuration file](https://github.com/florianv/laravel-swap/blob/master/config/swap.php). | ||
```php | ||
// Get the latest EUR/USD rate | ||
$rate = Swap::latest('EUR/USD'); | ||
|
||
## Usage | ||
// 1.129 | ||
$rate->getValue(); | ||
|
||
### Via the Facade | ||
// 2016-08-26 | ||
$rate->getDate()->format('Y-m-d'); | ||
|
||
```php | ||
Route::get('/', function () { | ||
$rate = Swap::quote('EUR/USD'); | ||
}); | ||
// Get the EUR/USD rate yesterday | ||
$rate = Swap::historical('EUR/USD', Carbon::yesterday()); | ||
``` | ||
|
||
### Via Injection | ||
## Documentation | ||
|
||
```php | ||
use Swap\SwapInterface; | ||
The complete documentation can be found [here](https://github.com/florianv/laravel-swap/blob/master/doc/readme.md). | ||
|
||
Route::get('/', function (SwapInterface $swap) { | ||
$rate = $swap->quote('EUR/USD'); | ||
}); | ||
``` | ||
## Services | ||
|
||
## License | ||
Here is the list of the currently implemented services. | ||
|
||
[MIT](https://github.com/florianv/laravel-swap/blob/master/LICENSE) | ||
| Service | Base Currency | Quote Currency | Historical | | ||
|---------------------------------------------------------------------------|----------------------|----------------|----------------| | ||
| [Fixer](http://fixer.io) | * | * | Yes | | ||
| [European Central Bank](http://www.ecb.europa.eu/home/html/index.en.html) | EUR | * | Yes | | ||
| [Google](http://www.google.com/finance) | * | * | No | | ||
| [Open Exchange Rates](https://openexchangerates.org) | USD (free), * (paid) | * | Yes | | ||
| [Xignite](https://www.xignite.com) | * | * | Yes | | ||
| [Yahoo](https://finance.yahoo.com) | * | * | No | | ||
| [WebserviceX](http://www.webservicex.net/ws/default.aspx) | * | * | No | | ||
| [National Bank of Romania](http://www.bnr.ro) | RON | * | No | | ||
| [Central Bank of the Republic of Turkey](http://www.tcmb.gov.tr) | * | TRY | No | | ||
| [Central Bank of the Czech Republic](http://www.cnb.cz) | * | CZK | No | | ||
| [currencylayer](https://currencylayer.com) | USD (free), * (paid) | * | Yes | | ||
|
||
[travis-url]: https://travis-ci.org/florianv/laravel-swap | ||
[travis-image]: http://img.shields.io/travis/florianv/laravel-swap.svg | ||
## Credits | ||
|
||
[version-url]: https://packagist.org/packages/florianv/laravel-swap | ||
[version-image]: http://img.shields.io/packagist/v/florianv/laravel-swap.svg | ||
- [Florian Voutzinos](https://github.com/florianv) | ||
- [All Contributors](https://github.com/florianv/laravel-swap/contributors) | ||
|
||
## License | ||
|
||
[downloads-url]: https://packagist.org/packages/florianv/laravel-swap | ||
[downloads-image]: https://img.shields.io/packagist/dt/florianv/laravel-swap.svg | ||
The MIT License (MIT). Please see [LICENSE](https://github.com/florianv/laravel-swap/blob/master/LICENSE) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.