Skip to content

Commit 3c464f8

Browse files
CopilotGrotax
andcommitted
Add migration examples to UPGRADE-6.0.md guide
Co-authored-by: Grotax <[email protected]>
1 parent 8e98090 commit 3c464f8

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

docs/upgrades/UPGRADE-6.0.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,42 @@ Several major changes in version 6.0:
55
- The factory has been removed. Use `new` to construct your FeedIO instance: `new \FeedIo\FeedIo($client, $logger)`
66
- Feed IO comes no longer bundled with a default HTTP client, but uses HTTPlug instead. To continue using Guzzle, please require `php-http/guzzle7-adapter`.
77
- Feed IO does no longer set a custom user agent. However, HTTP clients usually add a default themselves. If the feed you want to read requires a specific user agent, please configure your HTTP client accordingly, before you inject it into Feed IO.
8+
9+
## Migrating from Factory
10+
11+
### Before (5.x)
12+
```php
13+
use \FeedIo\Factory;
14+
15+
$feedIo = Factory::create()->getFeedIo();
16+
```
17+
18+
### After (6.0+)
19+
```php
20+
use \FeedIo\Adapter\Http\Client;
21+
use \Http\Discovery\Psr18ClientDiscovery;
22+
23+
$client = new Client(Psr18ClientDiscovery::find());
24+
$feedIo = new \FeedIo\FeedIo($client);
25+
```
26+
27+
### With Logging (6.0+)
28+
```php
29+
use \FeedIo\Adapter\Http\Client;
30+
use \Http\Discovery\Psr18ClientDiscovery;
31+
use Monolog\Logger;
32+
use Monolog\Handler\StreamHandler;
33+
34+
$client = new Client(Psr18ClientDiscovery::find());
35+
$logger = new Logger('feed-io', [new StreamHandler('php://stdout')]);
36+
$feedIo = new \FeedIo\FeedIo($client, $logger);
37+
```
38+
39+
### With Guzzle Client (6.0+)
40+
```php
41+
use \FeedIo\Adapter\Guzzle\Client;
42+
use \GuzzleHttp\Client as GuzzleClient;
43+
44+
$client = new Client(new GuzzleClient());
45+
$feedIo = new \FeedIo\FeedIo($client);
46+
```

0 commit comments

Comments
 (0)