You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-55Lines changed: 2 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,61 +58,7 @@ Benefits
58
58
Quick start
59
59
-----------
60
60
61
-
This quick start guide will walk through getting up and running with Porter from scratch and assumes you already have a PHP environment set up with Composer. Let's start by initializing our Composer file by running `composer init` in our project's root directory and accepting the defaults. We can skip defining dependencies interactively because we'll issue separate commands in a moment.
62
-
63
-
Let's start with the [European Central Bank][ECB provider] (ECB) provider by including it in our `composer.json` with the following command.
64
-
65
-
```sh
66
-
composer require provider/european-central-bank
67
-
```
68
-
69
-
We now have the provider installed along with all its dependencies, including Porter herself. We want to create a `new Porter` instance now, but we need to pass a `ContainerInterface` to her constructor. Any PSR-11 container is valid, but let's use Joomla DI for now.
70
-
71
-
```sh
72
-
composer require joomla/di
73
-
```
74
-
75
-
Create a new container and register an instance of `EuropeanCentralBankProvider` with it. Pass the container to a new Porter instance. Don't forget to include the autoloader!
76
-
77
-
```php
78
-
use Joomla\DI\Container;
79
-
use ScriptFUSION\Porter\Porter;
80
-
use ScriptFUSION\Porter\Provider\EuropeanCentralBank\Provider\EuropeanCentralBankProvider;
81
-
82
-
require 'vendor/autoload.php';
83
-
84
-
$container = new Container;
85
-
$container->set(EuropeanCentralBankProvider::class, new EuropeanCentralBankProvider);
86
-
87
-
$porter = new Porter($container);
88
-
```
89
-
90
-
We're now ready to import any of the ECB's resources. Let's import the latest daily foreign exchange rates provided by `DailyForexRates`. Porter's `import()` method requires an `ImportSpecification` that accepts the resource we want to import.
Porter returns an iterator so we can now loop over the rates and print them out.
97
-
98
-
```php
99
-
foreach ($rates as $rate) {
100
-
echo "$rate[currency]: $rate[rate]\n";
101
-
}
102
-
```
103
-
104
-
This outputs something similar to the following, with today's current rates.
105
-
106
-
>USD: 1.2304
107
-
JPY: 131.66
108
-
BGN: 1.9558
109
-
CZK: 25.357
110
-
DKK: 7.4469
111
-
...
112
-
113
-
Since these rates come from the European Central Bank, they're relative to the Euro (EUR), which is assumed to always be `1`. We can use this information to write a currency converter that's always up-to-date with the latest exchange rate information.
114
-
115
-
This just scratches the surface of Porter without going into any details. Explore the rest of this manual at your leisure to gain a fuller understanding of the features at your disposal.
61
+
To get started quickly, try our [quick start guide][Quickstart].
116
62
117
63
Understanding this manual
118
64
-------------------------
@@ -592,6 +538,7 @@ Porter is published under the open source GNU Lesser General Public License v3.0
This quick start guide will walk through getting up and running with Porter from scratch and assumes you already have a PHP environment set up with Composer. Let's start by initializing our Composer file by running `composer init` in our project's root directory and accepting the defaults. We can skip defining dependencies interactively because we'll issue separate commands in a moment.
2
+
3
+
Let's start with the [European Central Bank][ECB provider] (ECB) provider by including it in our `composer.json` with the following command.
4
+
5
+
```sh
6
+
composer require provider/european-central-bank
7
+
```
8
+
9
+
We now have the provider installed along with all its dependencies, including Porter herself. We want to create a `new Porter` instance now, but we need to pass a `ContainerInterface` to her constructor. Any PSR-11 container is valid, but let's use Joomla DI for now.
10
+
11
+
```sh
12
+
composer require joomla/di
13
+
```
14
+
15
+
Create a new container and register an instance of `EuropeanCentralBankProvider` with it. Pass the container to a new Porter instance. Don't forget to include the autoloader!
16
+
17
+
```php
18
+
use Joomla\DI\Container;
19
+
use ScriptFUSION\Porter\Porter;
20
+
use ScriptFUSION\Porter\Provider\EuropeanCentralBank\Provider\EuropeanCentralBankProvider;
21
+
22
+
require 'vendor/autoload.php';
23
+
24
+
$container = new Container;
25
+
$container->set(EuropeanCentralBankProvider::class, new EuropeanCentralBankProvider);
26
+
27
+
$porter = new Porter($container);
28
+
```
29
+
30
+
We're now ready to import any of the ECB's resources. Let's import the latest daily foreign exchange rates provided by `DailyForexRates`. Porter's `import()` method requires an `ImportSpecification` that accepts the resource we want to import.
Porter returns an iterator so we can now loop over the rates and print them out.
37
+
38
+
```php
39
+
foreach ($rates as $rate) {
40
+
echo "$rate[currency]: $rate[rate]\n";
41
+
}
42
+
```
43
+
44
+
This outputs something similar to the following, with today's current rates.
45
+
46
+
>USD: 1.2304
47
+
JPY: 131.66
48
+
BGN: 1.9558
49
+
CZK: 25.357
50
+
DKK: 7.4469
51
+
...
52
+
53
+
Since these rates come from the European Central Bank, they're relative to the Euro (EUR), which is assumed to always be *1*. We can use this information to write a currency converter that's always up-to-date with the latest exchange rate information.
54
+
55
+
This just scratches the surface of Porter without going into any details. Explore the [rest of the manual][Readme] at your leisure to gain a fuller understanding of the features at your disposal.
0 commit comments