Skip to content

Commit ab0fd26

Browse files
committed
Moved readme "quick start" section to separate document.
1 parent 703de2c commit ab0fd26

2 files changed

Lines changed: 62 additions & 55 deletions

File tree

README.md

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -58,61 +58,7 @@ Benefits
5858
Quick start
5959
-----------
6060

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.
91-
92-
```php
93-
$rates = $porter->import(new ImportSpecification(new DailyForexRates));
94-
```
95-
96-
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].
11662

11763
Understanding this manual
11864
-------------------------
@@ -592,6 +538,7 @@ Porter is published under the open source GNU Lesser General Public License v3.0
592538

593539
[Issues]: https://github.com/ScriptFUSION/Porter/issues
594540
[PRs]: https://github.com/ScriptFUSION/Porter/pulls
541+
[Quickstart]: https://github.com/ScriptFUSION/Porter/tree/master/docs/Quickstart.md
595542
[Provider]: https://github.com/provider
596543
[Porter transformers]: https://github.com/Porter-transformers
597544
[Porter connectors]: https://github.com/Porter-connectors

docs/Quickstart.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
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.
31+
32+
```php
33+
$rates = $porter->import(new ImportSpecification(new DailyForexRates));
34+
```
35+
36+
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.
56+
57+
[Back to main readme][Readme]
58+
59+
[Readme]: https://github.com/ScriptFUSION/Porter/blob/master/README.md
60+
[ECB provider]: https://github.com/Provider/European-Central-Bank

0 commit comments

Comments
 (0)