PHPackages                             cerbero/lazy-json-pages - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. cerbero/lazy-json-pages

ActiveLibrary[Queues &amp; Workers](/categories/queues)

cerbero/lazy-json-pages
=======================

Framework-agnostic package to load items from any paginated JSON API into a Laravel lazy collection via async HTTP requests.

2.0.1(1y ago)19697.4k↑27.1%2MITPHPPHP ^8.1

Since Aug 8Pushed 1y ago2 watchersCompare

[ Source](https://github.com/cerbero90/lazy-json-pages)[ Packagist](https://packagist.org/packages/cerbero/lazy-json-pages)[ Docs](https://github.com/cerbero90/lazy-json-pages)[ GitHub Sponsors](https://github.com/cerbero90)[ Fund](https://ko-fi.com/cerbero90)[ RSS](/packages/cerbero-lazy-json-pages/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependencies (10)Versions (5)Used By (0)

📜 Lazy JSON Pages
=================

[](#-lazy-json-pages)

[![Author](https://camo.githubusercontent.com/fffbc89ca2742dccf8be167716e04b7125a913abae0da6a488131999dab8ca25/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d617574686f72266d6573736167653d6365726265726f393026636f6c6f723d353041424631266c6f676f3d74776974746572267374796c653d666c61742d737175617265)](https://twitter.com/cerbero90)[![PHP Version](https://camo.githubusercontent.com/866e4aa728857182a8d6e720027e61e0adaea0ce9c0e595116cc84e31acb9a38/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6365726265726f2f6c617a792d6a736f6e2d70616765733f636f6c6f723d253233344635423933266c6f676f3d706870267374796c653d666c61742d737175617265)](https://www.php.net)[![Build Status](https://camo.githubusercontent.com/4fefeeabf0dd69b39e2bbec50544d40fe04d9027d92d302c18838922dfba162f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6365726265726f39302f6c617a792d6a736f6e2d70616765732f6275696c642e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265266c6f676f3d676974687562)](https://github.com/cerbero90/lazy-json-pages/actions?query=workflow%3Abuild)[![Coverage Status](https://camo.githubusercontent.com/815eb608387744cb14fc078c9d44f6594f24bd8f41620f9350e01084387b3fd1/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6365726265726f39302f6c617a792d6a736f6e2d70616765732e7376673f7374796c653d666c61742d737175617265266c6f676f3d7363727574696e697a6572)](https://scrutinizer-ci.com/g/cerbero90/lazy-json-pages/code-structure)[![Quality Score](https://camo.githubusercontent.com/829aa003431d9eb72c29607c43086809ac1c4757acd820672129eb369901eb16/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6365726265726f39302f6c617a792d6a736f6e2d70616765732e7376673f7374796c653d666c61742d737175617265266c6f676f3d7363727574696e697a6572)](https://scrutinizer-ci.com/g/cerbero90/lazy-json-pages)[![PHPStan Level](https://camo.githubusercontent.com/a297104012c8207e99eac313bcf680ff32843c3d3a21decb547f454bf4097ee2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6576656c2d6d61782d737563636573733f7374796c653d666c61742d737175617265266c6f676f3d646174613a696d6167652f706e673b6261736536342c6956424f5277304b47676f414141414e53556845556741414143414141414167434159414141427a656e72304141414762306c455156523432753158653142555a52532f79344b67386f6952334643434255795345535a4252436961426e6d45734f7a65537a73672b4b7859594f3964454566744e52715a6a78343046525a6b5470716d4f7a3553324c73586c455a42636961746b516e484447596147644679314570474d486c2f702f5064466c7432726b354f2b4a396e356e412f767466356e6564336c6e6c49537052686166426c4c524c4843744a475672422f5a4244736177326c55717a526547414334364473745459666e534347556a61614476677841436f366a337655656e4e64496d65525871646e575635617a3572726e7a655a7a6e6a384a2b4535467473636c68663373344a3443532f6f52783542766f6e385a553635464759517841776366383561374365527a2b4334315448656a75657964435a3741414b33346e7776336b48502f6f554b644f4c344b373235386646374375643432374f3438525165476b49474a37374e38665a716c726366525034642f78393057516648584c65427439645472536c776c33563635796e574c4d315345413271624e51636b626534586d77773130486d79337368696430434d636d6c454a745344736c35565a42646641674d7649337575522b6d6f4a714e364c61786d70734f42654c43446d546966434239325263516d6241554a767471414c63357351723870383667594243634664427139774f696e374e5161783665776c423672714c5a486632334650313079336c6a36754a74454267324878695643747a64335345774d4243696f364e6839757a5a344f2f764c774f5a344f554e4d324e79494750467276757a42472f2f6c5250732b5651326b316b692b65506b64383462736b7a375946705967697a457a3838503876507a596666753364445330674a4e545531515856304e71616d70524b31574977676669453471684f7969673072432b7043764b3851556f4d4c37754a564841356b635155703344537071576a6333642f4479386f4b696f694c6f367571436f614568754862314b765430394141684246706257346c4f70794d797949425153436d6f55514c517a676e694e767a2b6f624232485332527742674536644f7843794a6f676d4e6b503275315772687734514a30332b69477252395845643343544e426e366543626f3430775044774d645856314246314456473571694574626f78535550364a37312b44334e775541684c4f4952517a6d376c6e6e68595576375146762f79445a2f4c6d3575624b3244564939695a386252384a4474454235376c4e7a454e514e364f6a6f49476c70616249565a7359614d544f2b6872696b525241314a786d5358396845372f734a745679463338744b735543565a7842687a396a49337747542f514a6c41447a50417958726e6a306b496e7a47485143524d794f672f65643275486a784975453454675951487132444c4a71756d617368592b6c6e734d433447564335646f365856754b396c2b34536b4e38792b47665965564a6e32672b2b553751796750543064426759474944765435386d6e46355051636a433833507a5346396648375331745a47456841515a514f54384a61413331376f496b4d366a533875564c53447a4f517167323355682b4d6c6b4f66303047673063503334632b7676373455527a4d396e34316762792f7276766b63374f54686c415455334e4347594a5558743451614c75545977426354534f426d6a315244374434547369783442794f6a5a52462f7a677570444562675a336a346c792f71656b704e44306f35615134344853344f416773567174493167545a4f303149624730615031626b6e6e7843445576417248692b42306c4a536c7a676c5446594f3275644633516c39544372486e356f45497265487036516c5255464a53556c4a43717169705357566c4a38764c79434759494653374853337a476138376d76346c636a4c774c6c53746c4c544b59595555416c76726c444763573435774b785858366171485a4e75744d2b316f51424846546577414b6b6f48342b7671436a3438505941475335796235616d6a4e6f4f2b435532534c35334e4b70444430767848486d4f4a6972374c357855765a676d307573325231343253634f4979567159766c70575534586f4849503844584c32622b776a6457655868365532466a6d49494b6d625741595046524d75733632682f676549766a4f51596c707544797351724c4c364765723439486757386a7176585568493755764462396961535444714874794974694635537577356577462f4e6438564a367a6c68736e30366245687758344e79664376754745655270546d68346d6b47363879447079757a42394555636a553561776241676e63506c4165536441514552307a436e647a715662655843347144734d70764745594258526e734478344e33417566314643546a5449615674592f51546d643049386242566d316b656a45756255664f30317671496d6e336334395837717065714939696e4967746270784b3359724b66494a43742b4f6556326e665556465234636134456b56454e794137676b59634d66423152354d4d6d785a37657a2f324b463553534e3179562b3135385550734a54305a4263493262524c744958476f5975354665724f55694a65314f66734c335845574834336c324b532b694a46392b53344670634e6773632b6a3863543848346f31626650672f716b4c743530754a31527a644d7347673055717766454e313134507762314374575447672b59395535436c4b397837785557493742493556515670304156635133625a6b51686d6e45676448684b794e535a65313663727442496c63377349623663524c6674325043676f4b476a696a4244746a72415137613345644d73787a4952666c414649685062366d48596d5977582b57426c505167736b6867567279794a4351794e79424c73425164513666677351687974364d534f4f73575a37676248387745546d67524b41696a61744e4c384e676d30787834744c6373707330577a7834616c306a586c493430422f413370613134344d447453674141414141456c46546b5375516d4343)](https://phpstan.org/)[![Latest Version](https://camo.githubusercontent.com/5f1d2ee9b563294261b93ddb0a26a5f731b560d4ced0fbfa54169bb8b46a8875/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6365726265726f2f6c617a792d6a736f6e2d70616765732e7376673f6c6162656c3d76657273696f6e267374796c653d666c61742d737175617265)](https://packagist.org/packages/cerbero/lazy-json-pages)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![PER](https://camo.githubusercontent.com/84278b6753117019e91c00fda1fe3c0b04f80f38e435f191ddef6fe2069e2607/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d636f6d706c69616e6365266d6573736167653d50455226636f6c6f723d626c7565267374796c653d666c61742d737175617265)](https://www.php-fig.org/per/coding-style/)[![Total Downloads](https://camo.githubusercontent.com/f7a2914426174b609cccbc90f0ba9856be01e011e859f812fa61f5ec4f8470b8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6365726265726f2f6c617a792d6a736f6e2d70616765732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cerbero/lazy-json-pages)

```
use Illuminate\Support\LazyCollection;

LazyCollection::fromJsonPages($source)
    ->totalPages('pagination.total_pages')
    ->async(requests: 3)
    ->throttle(requests: 100, perMinutes: 1)
    ->collect('data.*');
```

Framework-agnostic API scraper to load items from any paginated JSON API into a [Laravel lazy collection](https://laravel.com/docs/collections#lazy-collections) via async HTTP requests.

Tip

Need to read large JSON with no pagination in a memory-efficient way?

Consider using [🐼 Lazy JSON](https://github.com/cerbero90/lazy-json) or [🧩 JSON Parser](https://github.com/cerbero90/json-parser) instead.

📦 Install
---------

[](#-install)

Via Composer:

```
composer require cerbero/lazy-json-pages
```

🔮 Usage
-------

[](#-usage)

- [👣 Basics](#-basics)
- [💧 Sources](#-sources)
- [🏛️ Pagination structure](#%EF%B8%8F-pagination-structure)
- [📏 Length-aware paginations](#-length-aware-paginations)
- [↪️ Cursor-aware paginations](#%EF%B8%8F-cursor-aware-paginations)
- [🔗 Link header paginations](#-link-header-paginations)
- [👽 Custom paginations](#-custom-paginations)
- [🚀 Requests optimization](#-requests-optimization)
- [💢 Errors handling](#-errors-handling)
- [🤝 Laravel integration](#-laravel-integration)

### 👣 Basics

[](#-basics)

Depending on our coding style, we can instantiate Lazy JSON Pages in 4 different ways:

```
use Cerbero\LazyJsonPages\LazyJsonPages;
use Illuminate\Support\LazyCollection;

use function Cerbero\LazyJsonPages\lazyJsonPages;

// lazy collection macro
LazyCollection::fromJsonPages($source);

// classic instantiation
new LazyJsonPages($source);

// static method
LazyJsonPages::from($source);

// namespaced helper
lazyJsonPages($source);
```

The variable `$source` in our examples represents any [source](#-sources) that points to a paginated JSON API. Once we define the source, we can then chain methods to define how the API is paginated:

```
$lazyCollection = LazyJsonPages::from($source)
    ->totalItems('pagination.total_items')
    ->offset()
    ->collect('results.*');
```

When calling `collect()`, we indicate that the pagination structure is defined and that we are ready to collect the paginated items within a [Laravel lazy collection](https://laravel.com/docs/collections#lazy-collections), where we can loop through the items one by one and apply filters and transformations in a memory-efficient way.

### 💧 Sources

[](#-sources)

A source is any means that can point to a paginated JSON API. A number of sources is supported by default:

- **endpoint URIs**, e.g. `https://example.com/api/v1/users` or any instance of `Psr\Http\Message\UriInterface`
- **PSR-7 requests**, i.e. any instance of `Psr\Http\Message\RequestInterface`
- **Laravel HTTP client requests**, i.e. any instance of `Illuminate\Http\Client\Request`
- **Laravel HTTP client responses**, i.e. any instance of `Illuminate\Http\Client\Response`
- **Laravel HTTP requests**, i.e. any instance of `Illuminate\Http\Request`
- **Symfony requests**, i.e. any instance of `Symfony\Component\HttpFoundation\Request`
- **user-defined sources**, i.e. any instance of `Cerbero\LazyJsonPages\Sources\Source`

Here are some examples of sources:

```
// a simple URI string
$source = 'https://example.com/api/v1/users';

// any PSR-7 compatible request is supported, including Guzzle requests
$source = new GuzzleHttp\Psr7\Request('GET', 'https://example.com/api/v1/users');

// while being framework-agnostic, Lazy JSON Pages integrates well with Laravel
$source = Http::withToken($bearer)->get('https://example.com/api/v1/users');
```

If none of the above sources satifies our use case, we can implement our own source.

**Click here to see how to implement a custom source.**To implement a custom source, we need to extend `Source` and implement 2 methods:

```
use Cerbero\LazyJsonPages\Sources\Source;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

class CustomSource extends Source
{
    public function request(): RequestInterface
    {
        // return a PSR-7 request
    }

    public function response(): ResponseInterface
    {
        // return a PSR-7 response
    }
}
```

The parent class `Source` gives us access to 2 properties:

- `$source`: the custom source for our use case
- `$client`: the Guzzle HTTP client

The methods to implement turn our custom source into a PSR-7 request and a PSR-7 response. Please refer to the [already existing sources](https://github.com/cerbero90/json-parser/tree/master/src/Sources) to see some implementations.

Once the custom source is implemented, we can instruct Lazy JSON Pages to use it:

```
LazyJsonPages::from(new CustomSource($source));
```

If you find yourself implementing the same custom source in different projects, feel free to send a PR and we will consider to support your custom source by default. Thank you in advance for any contribution!

### 🏛️ Pagination structure

[](#️-pagination-structure)

After defining the [source](#-sources), we need to let Lazy JSON Pages know what the paginated API looks like.

If the API uses a query parameter different from `page` to specify the current page - for example `?current_page=1` - we can chain the method `pageName()`:

```
LazyJsonPages::from($source)->pageName('current_page');
```

Otherwise, if the number of the current page is present in the URI path - for example `https://example.com/users/page/1` - we can chain the method `pageInPath()`:

```
LazyJsonPages::from($source)->pageInPath();
```

By default the last integer in the URI path is considered the page number. However we can customize the regular expression used to capture the page number, if need be:

```
LazyJsonPages::from($source)->pageInPath('~/page/(\d+)$~');
```

Some API paginations may start with a page different from `1`. If that's the case, we can define the first page by chaining the method `firstPage()`:

```
LazyJsonPages::from($source)->firstPage(0);
```

Now that we have customized the basic structure of the API, we can describe how items are paginated depending on whether the pagination is [length-aware](#-length-aware-paginations) or [cursor](#%EF%B8%8F-cursor-and-next-page-paginations) based.

### 📏 Length-aware paginations

[](#-length-aware-paginations)

The term "length-aware" indicates any pagination containing at least one of the following length information:

- the total number of pages
- the total number of items
- the number of the last page

Lazy JSON Pages only needs one of these details to work properly:

```
LazyJsonPages::from($source)->totalPages('pagination.total_pages');

LazyJsonPages::from($source)->totalItems('pagination.total_items');

LazyJsonPages::from($source)->lastPage('pagination.last_page');
```

If the length information is nested in the JSON body, we can use dot-notation to indicate the level of nesting. For example, `pagination.total_pages` means that the total number of pages sits in the object `pagination`, under the key `total_pages`.

Otherwise, if the length information is displayed in the headers, we can use the same methods to gather it by simply defining the name of the header:

```
LazyJsonPages::from($source)->totalPages('X-Total-Pages');

LazyJsonPages::from($source)->totalItems('X-Total-Items');

LazyJsonPages::from($source)->lastPage('X-Last-Page');
```

APIs can expose their length information in the form of numbers (`total_pages: 10`) or URIs (`last_page: "https://example.com?page=10"`), Lazy JSON Pages supports both.

If the pagination works with an offset, we can configure it with the `offset()` method. The value of the offset will be calculated based on the number of items present on the first page:

```
// indicate that the offset is defined by the `offset` query parameter, e.g. ?offset=50
LazyJsonPages::from($source)
    ->totalItems('pagination.total_items')
    ->offset();

// indicate that the offset is defined by the `skip` query parameter, e.g. ?skip=50
LazyJsonPages::from($source)
    ->totalItems('pagination.total_items')
    ->offset('skip');
```

### ↪️ Cursor-aware paginations

[](#️-cursor-aware-paginations)

Not all paginations are [length-aware](#-length-aware-paginations), some may be built in a way where each page has a cursor pointing to the next page.

We can tackle this kind of pagination by indicating the key or the header holding the cursor:

```
LazyJsonPages::from($source)->cursor('pagination.cursor');

LazyJsonPages::from($source)->cursor('X-Cursor');
```

The cursor may be a number, a string or a URI: Lazy JSON Pages supports them all.

### 🔗 Link header paginations

[](#-link-header-paginations)

Some paginated API responses include a header called `Link`. An example is [GitHub](https://api.github.com/repos/octocat/hello-world/issues?state=open): if we inspect the response headers, we can see the `Link` header looking like this:

```
; rel="next",
; rel="last"

```

To lazy-load items from a Link header pagination, we can chain the method `linkHeader()`:

```
LazyJsonPages::from($source)->linkHeader();
```

### 👽 Custom paginations

[](#-custom-paginations)

Lazy JSON Pages provides several methods to extract items from the most popular pagination mechanisms. However if we need a custom solution, we can implement our own pagination.

**Click here to see how to implement a custom pagination.**To implement a custom pagination, we need to extend `Pagination` and implement 1 method:

```
use Cerbero\LazyJsonPages\Paginations\Pagination;
use Traversable;

class CustomPagination extends Pagination
{
    public function getIterator(): Traversable
    {
        // return a Traversable yielding the paginated items
    }
}
```

The parent class `Pagination` gives us access to 3 properties:

- `$source`: the [source](#-sources) pointing to the paginated JSON API
- `$client`: the Guzzle HTTP client
- `$config`: the configuration that we generated by chaining methods like `totalPages()`

The method `getIterator()` defines the logic to extract paginated items in a memory-efficient way. Please refer to the [already existing paginations](https://github.com/cerbero90/json-parser/tree/master/src/Paginations) to see some implementations.

Once the custom pagination is implemented, we can instruct Lazy JSON Pages to use it:

```
LazyJsonPages::from($source)->pagination(CustomPagination::class);
```

If you find yourself implementing the same custom pagination in different projects, feel free to send a PR and we will consider to support your custom pagination by default. Thank you in advance for any contribution!

### 🚀 Requests optimization

[](#-requests-optimization)

Paginated APIs differ from each other, so Lazy JSON Pages lets us tweak our HTTP requests specifically for our use case.

By default HTTP requests are sent synchronously. If we want to send more than one request without waiting for the response, we can call the `async()` method and set the number of concurrent requests:

```
LazyJsonPages::from($source)->async(requests: 5);
```

Note

Please note that asynchronous requests improve speed at the expense of memory, as more responses are going to be loaded at once.

Several APIs set rate limits to reduce the number of allowed requests for a period of time. We can instruct Lazy JSON Pages to respect such limits by throttling our requests:

```
// we send a maximum of 3 requests per second, 60 per minute and 3,000 per hour
LazyJsonPages::from($source)
    ->throttle(requests: 3, perSeconds: 1)
    ->throttle(requests: 60, perMinutes: 1)
    ->throttle(requests: 3000, perHours: 1);
```

Internally, Lazy JSON Pages uses [Guzzle](https://docs.guzzlephp.org) as its HTTP client. We can customize the client behavior by adding as many [middleware](https://docs.guzzlephp.org/en/stable/handlers-and-middleware.html#middleware) as we need:

```
LazyJsonPages::from($source)
    ->middleware('log_requests', $logRequests)
    ->middleware('cache_responses', $cacheResponses);
```

If we need a middleware to be added every time we invoke Lazy JSON Pages, we can add a global middleware:

```
LazyJsonPages::globalMiddleware('fire_events', $fireEvents);
```

Sometimes writing [Guzzle middleware](https://docs.guzzlephp.org/en/stable/handlers-and-middleware.html#middleware) might be cumbersome. Alternatively Lazy JSON Pages provides convenient methods to fire callbacks when sending a request or receiving a response:

```
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

LazyJsonPages::from($source)
    ->onRequest(fn(RequestInterface $request) => ...)
    ->onResponse(fn(ResponseInterface $response, RequestInterface $request) => ...);
```

We can also tweak the number of allowed seconds before an API connection times out or the allowed duration of the entire HTTP request (by default they are both set to 5 seconds):

```
LazyJsonPages::from($source)
    ->connectionTimeout(7)
    ->requestTimeout(10);
```

If the 3rd party API is faulty or error-prone, we can indicate how many times we want to retry failing HTTP requests and the backoff strategy to compute the milliseconds to wait before retrying (by default failing requests are repeated 3 times after an exponential backoff of 100, 400 and 900 milliseconds):

```
// repeat failing requests 5 times after a backoff of 1, 2, 3, 4 and 5 seconds
LazyJsonPages::from($source)
    ->attempts(5)
    ->backoff(fn(int $attempt) => $attempt * 1000);
```

### 💢 Errors handling

[](#-errors-handling)

If something goes wrong during the scraping process, we can intercept the error and execute a custom logic to handle it:

```
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

LazyJsonPages::from($source)
    ->onError(fn(Throwable $e, RequestInterface $request, ?ResponseInterface $response) => ...);
```

Any exception thrown by this package extends the `LazyJsonPagesException` class. This makes it easy to handle all exceptions in a single catch block:

```
use Cerbero\LazyJsonPages\Exceptions\LazyJsonPagesException;

try {
    LazyJsonPages::from($source)->linkHeader()->collect()->each(...);
} catch (LazyJsonPagesException $e) {
    // handle any exception thrown by Lazy JSON Pages
}
```

For reference, here is a comprehensive table of all the exceptions thrown by this package:

`Cerbero\LazyJsonPages\Exceptions\`thrown when`InvalidKeyException`a JSON key does not contain a valid value`InvalidPageInPathException`a page cannot be found in the URI path`InvalidPaginationException`a pagination implementation is not valid`OutOfAttemptsException`an HTTP request failed too many times`RequestNotSentException`a JSON source didn't send any HTTP request`UnsupportedPaginationException`a pagination is not supported`UnsupportedSourceException`a JSON source is not supported### 🤝 Laravel integration

[](#-laravel-integration)

If used in a [Laravel](https://laravel.com) project, Lazy JSON Pages automatically fires events when:

- an HTTP request is about to be sent, by firing `Illuminate\Http\Client\Events\RequestSending`
- an HTTP response is received, by firing `Illuminate\Http\Client\Events\ResponseReceived`
- a connection failed, by firing `Illuminate\Http\Client\Events\ConnectionFailed`

This is especially handy for debugging tools like [Laravel Telescope](https://laravel.com/docs/telescope) or [Spatie Ray](https://spatie.be/docs/ray/installation-in-your-project/laravel) or for triggering the related event listeners.

📆 Change log
------------

[](#-change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

🧪 Testing
---------

[](#-testing)

```
composer test
```

💞 Contributing
--------------

[](#-contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

🧯 Security
----------

[](#-security)

If you discover any security related issues, please email  instead of using the issue tracker.

🏅 Credits
---------

[](#-credits)

- [Andrea Marco Sartori](https://twitter.com/cerbero90)
- [All Contributors](../../contributors)

⚖️ License
----------

[](#️-license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~566 days

Total

3

Last Release

613d ago

Major Versions

1.0.0 → 2.0.02024-09-10

PHP version history (2 changes)1.0.0PHP ^7.2||^8.0

2.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/596523?v=4)[Matteo Picciolini](/maintainers/cerbero)[@cerbero](https://github.com/cerbero)

---

Top Contributors

[![cerbero90](https://avatars.githubusercontent.com/u/5838106?v=4)](https://github.com/cerbero90 "cerbero90 (151 commits)")

---

Tags

apijsonlaravellazypaginationparserphpscraperscrapingstreamjsonasynclaravelparserpaginationcollectionlazy

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cerbero-lazy-json-pages/health.svg)

```
[![Health](https://phpackages.com/badges/cerbero-lazy-json-pages/health.svg)](https://phpackages.com/packages/cerbero-lazy-json-pages)
```

###  Alternatives

[cerbero/lazy-json

Framework-agnostic package to load JSONs of any dimension and from any source into Laravel lazy collections.

254309.8k1](/packages/cerbero-lazy-json)[amphp/parser

A generator parser to make streaming parsers simple.

14952.8M16](/packages/amphp-parser)[phootwork/collection

The phootwork library fills gaps in the php language and provides better solutions than the existing ones php offers.

3924.8M15](/packages/phootwork-collection)[rodenastyle/stream-parser

PHP Multiformat Streaming Parser

443195.7k2](/packages/rodenastyle-stream-parser)[toin0u/geotools-laravel

Geo-related tools PHP library for Laravel 4 &amp; 5

250388.0k1](/packages/toin0u-geotools-laravel)[rcrowe/raven

Raven client for Sentry that supports background processing through multiple providers.

3467.0k](/packages/rcrowe-raven)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
