Skip to content

Commit 36975ad

Browse files
author
Camille Baronnet
committed
Add LICENSE, improve README and fix typo
1 parent 06b2e5e commit 36975ad

File tree

5 files changed

+46
-9
lines changed

5 files changed

+46
-9
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 CristalTeam
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
# PHP API Wrapper
22

3+
[![Latest Stable Version](https://img.shields.io/packagist/v/cristal/php-api-wrapper.svg?style=flat-square)](https://packagist.org/packages/cristal/php-api-wrapper)
4+
[![GitHub issues](https://img.shields.io/github/issues/cristalTeam/php-api-wrapper.svg?style=flat-square)](https://github.com/cristalTeam/php-api-wrapper/issues)
5+
[![GitHub license](https://img.shields.io/github/license/cristalTeam/php-api-wrapper.svg?style=flat-square)](https://github.com/cristalTeam/php-api-wrapper/blob/master/LICENSE)
6+
7+
8+
## Installation using Composer
9+
10+
```bash
11+
composer require cristal/php-api-wrapper
12+
```
13+
14+
## Usage
15+
316
PHP API Wrapper is a Laravel Eloquent like, built to work with APIs. The integration of each API consists of three steps:
417

518
- The Transport
619
- The Wrapper
720
- The Models and Builder
821

9-
## 1. The Transport
22+
### 1. The Transport
1023

1124
The Transport is an implementation of `TransportInterface`, it manages the API Autentication,
1225
returns desialized data, and manage HTTP errors with `ApiException` and childs (see `src/Exceptions`).
@@ -31,7 +44,7 @@ $users = $transport->request('/users');
3144

3245
```
3346

34-
## 2. The Wrapper
47+
### 2. The Wrapper
3548

3649
A wrapper is a standalone class that must follow a specific implementation.
3750
For example, consider a User (create, read, delete and update), implementation. Here's what your wrapper should look like :
@@ -96,7 +109,7 @@ class CustomWraper extends Api
96109
}
97110
```
98111

99-
# 3. Chose your stack
112+
## 3. Chose your stack
100113

101114
- [Work without Laravel or Symfony](docs/work-standalone.md)
102115
- [Work with Laravel](docs/work-with-laravel.md)

composer.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
},
1313
"suggest": {
1414
"barryvdh/laravel-debugbar": "To support request tracking in your Laravel app.",
15-
"laravel/framework": "To integrate Laravel Collection, Pagination and Eloquent relations with your models."
15+
"laravel/framework": "To integrate Laravel Collection, Pagination and Eloquent relations with your models.",
16+
"symfony/symfony" : "To integrate a ManagerRegistry, a Paginator and support serialization with your entities.",
17+
"api-platform/core" : "To integrate a DataProvider and support the Paginator of the Api Platform in addition to the support of Symfony.",
18+
"league/oauth2-client" : "To support OAuth2 request Transport."
1619
},
1720
"autoload": {
1821
"psr-4": {

docs/work-standalone.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ Congratulation, you are quite ready to use your implementation like Eloquent :
4646
```php
4747
<?php
4848

49-
$activedUser = User::where(['active' => true])->get();
49+
$activedUsers = User::where(['active' => true])->get();
5050

51-
foreach($activedUser as $user){
51+
foreach($activedUsers as $user){
5252
$user->active = false;
5353
$user->save();
5454
}

docs/work-with-laravel.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class AppServiceProvider extends ServiceProvider
2121
{
2222
public function boot(): void
2323
{
24-
Model::setApi($this->app->mak(Api::class));
24+
Model::setApi($this->app->make(Api::class));
2525
}
2626

2727
public function register()
@@ -69,9 +69,9 @@ Congratulation, you are quite ready to use your implementation like Eloquent :
6969
```php
7070
<?php
7171

72-
$activedUser = User::where(['active' => true])->get();
72+
$activedUsers = User::where(['active' => true])->get();
7373

74-
foreach($activedUser as $user){
74+
foreach($activedUsers as $user){
7575
$user->active = false;
7676
$user->save();
7777
}

0 commit comments

Comments
 (0)