PHP code example of alexanderpavlov / stream-parser
1. Go to this page and download the library: Download alexanderpavlov/stream-parser library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alexanderpavlov / stream-parser example snippets
use Tightenco\Collect\Support\Collection;
StreamParser::xml("https://example.com/users.xml")->each(function(Collection $user){
dispatch(new App\Jobs\SendEmail($user));
});
use Tightenco\Collect\Support\Collection;
StreamParser::xml("https://example.com/books.xml")->each(function(Collection $book){
var_dump($book);
var_dump($book->get('comments')->toArray());
});
use Tightenco\Collect\Support\Collection;
StreamParser::json("https://example.com/books.json")->each(function(Collection $book){
var_dump($book->get('comments')->count());
});
use Tightenco\Collect\Support\Collection;
StreamParser::csv("https://example.com/books.csv")->each(function(Collection $book){
var_dump($book->get('comments')->last());
});
class Tightenco\Collect\Support\Collection#19 (1) {
protected $items =>
array(4) {
'ISBN' =>
string(13) "10-000000-001"
'title' =>
string(25) "The Iliad and The Odyssey"
'price' =>
string(5) "12.95"
'comments' =>
class Tightenco\Collect\Support\Collection#17 (1) {
protected $items =>
array(2) {
...
}
}
}
}
array(2) {
[0] =>
array(2) {
'rating' =>
string(1) "4"
'userComment' =>
string(27) "Best translation I've read."
}
[1] =>
array(2) {
'rating' =>
string(1) "2"
'userComment' =>
string(29) "I like other versions better."
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.