Laravel Montréal #13 - January 28th, 2016
Thanks for comming !
Jobs
Get involved
php artisan controller:make ContactsController
$api->version('v1', function ($api) {
$api->resource('users', 'App\Http\Controllers\Api\V1\UserController');
});
class UsersController extends BaseController {
public function index() {} // GET /
public function create() {} // GET /create
public function store() {} // POST /
public function show($id) {} // GET /1
public function edit($id) {} // GET /1/edit
public function update($id) {} // PUT /1
public function destroy($id) {} // DELETE /1
}
php artisan api:routes
Let's start with Basic authentication
$api->version('v1', ['middleware' => 'api.auth'], function ($api) {
$api->resource('users', 'App\Http\Controllers\Api\V1\UserController');
});
Now what about JWT ?
$api->version('v1', ['middleware' => 'api.auth'], function ($api) {
$api->resource('users', 'App\Http\Controllers\Api\V1\UserController');
});
$api->version('v2', ['middleware' => 'api.auth', 'providers' => ['basic', 'jwt']], function ($api) {
$api->resource('users', 'App\Http\Controllers\Api\V1\UserController');
});
There's three different trees: x, prs, and vnd. The standards tree you use will
depend upon the project you're developing.
The unregistered tree (x) is primarily meant for local or private environments.
The personal tree (prs) is primarily meant for projects that are not distributed commerically.
The vendor tree (vnd) is primarily meant for projects that are publically available and distributed.
Subtypes using the personal or vendor trees are technically meant to register with the IANA.
You can configure this in your .env file.
API_STANDARDS_TREE=vnd
Accept: application/vnd.LaravelMontrealv1+json