@@ -33,42 +33,31 @@ composer require php-http/guzzle6-adapter
3333
3434See [ Bind clients] ( #bind-clients ) if you want to use your own HTTP client or use specific configuration options.
3535
36- ### Laravel Service Provider
36+ ### Laravel
3737
38- If you are using Laravel < 5.5 or have disabled package auto discover, you must add the service provider to your ` config/app.php ` file:
38+ This package includes some Laravel specific classes to make it easier to use it with Laravel.
39+
40+ #### Service Provider and Facade Aliases
41+
42+ The required service provider and some facade aliases are automatically discovered by Laravel.
43+ However, if you've disabled package auto discover, you must add the service provider and optionally the facade aliases to your ` config/app.php ` file:
3944
4045``` php
4146'providers' => [
4247 ...,
4348 \Swis\JsonApi\Client\Providers\ServiceProvider::class,
4449],
50+ 'aliases' => [
51+ ...,
52+ 'DocumentFactory' => \Swis\JsonApi\Client\Facades\DocumentFactoryFacade::class,
53+ 'DocumentParser' => \Swis\JsonApi\Client\Facades\DocumentParserFacade::class,
54+ 'ItemHydrator' => \Swis\JsonApi\Client\Facades\ItemHydratorFacade::class,
55+ 'ResponseParser' => \Swis\JsonApi\Client\Facades\ResponseParserFacade::class,
56+ 'TypeMapper' => \Swis\JsonApi\Client\Facades\TypeMapperFacade::class,
57+ ],
4558```
4659
47-
48- ## Getting started
49-
50- You can simply require the [ DocumentClient] ( #documentclient ) as a dependency and use it in your class.
51- Alternatively, you can create a repository based on ` \Swis\JsonApi\Client\Repository ` and use that as a dependency:
52-
53- ``` php
54- use Swis\JsonApi\Client\Repository
55-
56- class BlogRepository extends Repository
57- {
58- protected $endpoint = 'blogs';
59- }
60-
61- $repository = app(BlogRepository::class);
62- $document = $repository->all();
63- if ($document->hasErrors()) {
64- // do something with errors
65- } else {
66- $blogs = $document->getData();
67- }
68- ```
69-
70-
71- ## Configuration
60+ #### Configuration
7261
7362The following is the default configuration provided by this package:
7463
@@ -88,15 +77,36 @@ return [
8877];
8978```
9079
91- ### Publish Configuration
92-
9380If you would like to make changes to the default configuration, publish and edit the configuration file:
9481
9582``` bash
9683php artisan vendor:publish --provider=" Swis\JsonApi\Client\Providers\ServiceProvider" --tag=" config"
9784```
9885
9986
87+ ## Getting started
88+
89+ You can simply require the [ DocumentClient] ( #documentclient ) as a dependency and use it in your class.
90+ Alternatively, you can create a repository based on ` \Swis\JsonApi\Client\Repository ` and use that as a dependency:
91+
92+ ``` php
93+ use Swis\JsonApi\Client\Repository
94+
95+ class BlogRepository extends Repository
96+ {
97+ protected $endpoint = 'blogs';
98+ }
99+
100+ $repository = app(BlogRepository::class);
101+ $document = $repository->all();
102+ if ($document->hasErrors()) {
103+ // do something with errors
104+ } else {
105+ $blogs = $document->getData();
106+ }
107+ ```
108+
109+
100110## Items
101111
102112By default, all items are an instance of ` \Swis\JsonApi\Client\Item ` .
0 commit comments