Skip to content
This repository was archived by the owner on Nov 14, 2020. It is now read-only.

Commit aa5d443

Browse files
committed
Initial Commit
0 parents  commit aa5d443

17 files changed

+1381
-0
lines changed

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Sehr gute GmbH
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
13+
all 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
21+
THE SOFTWARE.

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# laravel5-api
2+
3+
A modular controller for exposing your Laravel 5 Eloquent models as a REST API. All you need to do is to create one subclass of the controller per model and set up the routes.
4+
5+
## Usage
6+
7+
Subclass `SehrGut\Laravel5_Api\Controller` and set the eloquent model your controller should expose. Example:
8+
9+
```php
10+
use SehrGut\Laravel5_Api\Controller as ApiController;
11+
use App\Models\Post;
12+
13+
class PostsController extends ApiController
14+
{
15+
protected $model = Post::class;
16+
}
17+
```
18+
19+
You now have a controller with the same handlers as a [Laravel Resource Controller](https://laravel.com/docs/5.2/controllers#restful-resource-controllers):
20+
21+
Those methods can now be used to create the following routes:
22+
23+
```php
24+
Route::get('/posts', 'PostsController@index');
25+
Route::post('/posts', 'PostsController@store');
26+
Route::get('/posts/{post_id}', 'PostsController@show');
27+
Route::put('/posts/{post_id}', 'PostsController@update');
28+
Route::delete('/posts/{post_id}', 'PostsController@destroy');
29+
```
30+
31+
## Components
32+
33+
### Controller
34+
35+
#### Handlers
36+
37+
- `index()` - Fetch all resources
38+
- `store()` - Create a new resource
39+
- `show()` - Fetch a single resource
40+
- `update()` - Update a single resource
41+
- `destroy()` - Delete a single resource
42+
43+
### RequestAdapter
44+
### Formatter
45+
### Validator
46+
### Transformer
47+
### ModelMapping
48+
49+
## Customization
50+
51+
### Authorization
52+
53+
## Compatibility
54+
55+
* Tested with Laravel 5.2
56+
* Works with PHP 5.4 upwards
57+
58+
## License
59+
60+
This software is licensed under the [MIT License](https://opensource.org/licenses/MIT). See [LICENSE.txt](LICENSE.txt) for details.

composer.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "sehrgut/laravel5-api",
3+
"description": "A modular controller for exposing your Laravel 5 Eloquent models as a REST API.",
4+
"homepage": "http://github.com/sehrgutesoftware/laravel5-api",
5+
"type": "library",
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "Joseph Paul",
10+
"email": "[email protected]"
11+
},
12+
{
13+
"name": "Jalil Wahdatehagh",
14+
"email": "[email protected]"
15+
}
16+
],
17+
"require": {
18+
"php": ">=5.4",
19+
"laravel/framework": "5.*"
20+
},
21+
"autoload": {
22+
"psr-4": {"SehrGut\\Laravel5_Api\\": "src/Laravel5_Api"}
23+
}
24+
}

0 commit comments

Comments
 (0)