Skip to content

Commit

Permalink
Merge pull request #10 from LukeC8/patch-1
Browse files Browse the repository at this point in the history
Update Readme to be compatible with CakePHP 4
  • Loading branch information
bcrowe authored May 10, 2021
2 parents 66a6843 + 20bbc76 commit 707ab84
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,19 @@ Via Composer
$ composer require bcrowe/cakephp-api-pagination
```

Load the plugin in your application's `bootstrap.php` file:
Load the plugin by adding `$this->addPlugin('BryanCrowe/ApiPagination');` to the `bootsrap` method in your project’s `src/Application.php`:

``` php
Plugin::load('BryanCrowe/ApiPagination');
public function bootstrap(): void
{
parent::bootstrap();

// ... bootstrap code ...

// load more plugins here

$this->addPlugin('BryanCrowe/ApiPagination');
}
```

## Usage
Expand All @@ -40,10 +49,9 @@ Then, go ahead and set your paginated view variable like so:

``` php
$this->set('articles', $this->paginate($this->Articles));
$this->set('_serialize', ['articles']);
$this->viewBuilder()->setOption('serialize', ['articles']);
```

**Note:** It is important that your `_serialize` variable is an array, e.g.
**Note:** It is important that your `serialize` option is an array, e.g.
`['articles']`, so that your pagination information can be set under its own
pagination key.

Expand Down Expand Up @@ -165,4 +173,4 @@ information.
[link-downloads]: https://packagist.org/packages/bcrowe/cakephp-api-pagination
[link-author]: https://github.com/bcrowe
[link-contributors]: ../../contributors
[link-dataviews]: http://book.cakephp.org/3.0/en/views/json-and-xml-views.html#enabling-data-views-in-your-application
[link-dataviews]: https://book.cakephp.org/4/en/views/json-and-xml-views.html#enabling-data-views-in-your-application

0 comments on commit 707ab84

Please sign in to comment.