|
6 | 6 | <?php |
7 | 7 | require 'vendor/autoload.php'; |
8 | 8 |
|
9 | | -use \FeedIo\Factory; |
| 9 | +// create a simple FeedIo instance, e.g. with the Symfony HTTP Client |
| 10 | +$client = new \FeedIo\Adapter\Http\Client(new Symfony\Component\HttpClient\HttplugClient()); |
| 11 | +$feedIo = new \FeedIo\FeedIo($client); |
10 | 12 |
|
11 | | -$feedIo = Factory::create()->getFeedIo(); |
12 | 13 | $result = $feedIo->read('http://php.net/feed.atom'); |
13 | 14 |
|
14 | 15 | echo "feed title : {$result->getFeed()->getTitle()} \n"; |
@@ -54,8 +55,9 @@ feed-io is designed to read feeds across the internet and to publish your own. I |
54 | 55 |
|
55 | 56 | ```php |
56 | 57 | <?php |
57 | | -// create a simple FeedIo instance |
58 | | -$feedIo = \FeedIo\Factory::create()->getFeedIo(); |
| 58 | +// create a simple FeedIo instance, e.g. with the Symfony HTTP Client |
| 59 | +$client = new \FeedIo\Adapter\Http\Client(new Symfony\Component\HttpClient\HttplugClient()); |
| 60 | +$feedIo = new \FeedIo\FeedIo($client); |
59 | 61 |
|
60 | 62 | // read a feed |
61 | 63 | $result = $feedIo->read($url); |
@@ -124,14 +126,18 @@ $feed->add($item); |
124 | 126 |
|
125 | 127 | ## Activate logging |
126 | 128 |
|
127 | | -feed-io natively supports PSR-3 logging, you can activate it by choosing a 'builder' in the factory : |
| 129 | +feed-io natively supports PSR-3 logging, you can activate it by injecting a logger when creating the FeedIo instance : |
128 | 130 |
|
129 | 131 | ```php |
130 | | -$feedIo = \FeedIo\Factory::create(['builder' => 'monolog'])->getFeedIo(); |
| 132 | +use Monolog\Logger; |
| 133 | +use Monolog\Handler\StreamHandler; |
| 134 | + |
| 135 | +$client = new \FeedIo\Adapter\Http\Client(new Symfony\Component\HttpClient\HttplugClient()); |
| 136 | +$logger = new Logger('feed-io', [new StreamHandler('php://stdout')]); |
| 137 | +$feedIo = new \FeedIo\FeedIo($client, $logger); |
131 | 138 | ``` |
132 | 139 |
|
133 | | -feed-io only provides a builder to create Monolog\Logger instances. You can write your own, as long as the Builder implements BuilderInterface. |
134 | | -Building a FeedIo instance without the factory |
| 140 | +## Building a FeedIo instance |
135 | 141 |
|
136 | 142 | To create a new FeedIo instance you only need to inject two dependencies : |
137 | 143 |
|
|
0 commit comments