1. Go to this page and download the library: Download eilander/api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$apiRoute = config('api.route.'.config('api.version')); //change this if other versions are available
Route::group($apiRoute, function() {
Route::group([‘middleware’ => ‘Eilander\Api\Http\Middleware\AuthenticateApiKey’], function() {
Route::resource('gebruiker', 'GebruikerController');
//{{builder_api_routes}}
});
});
public function index()
{
$items = new Collection([‘one’,’two’,’three’]);
// Calling with a single argument returns a json response
return $this->response($items);
}
public function index()
{
$items = new Collection([‘one’,’two’,’three’]);
// Calling with no argument returns the response object
return $this->response()->data($items);
}
public function find($id)
{
$item = Item::find($id);
if ( ! $item ) {
// Using the response object you can call helper methods.
return $this->response()->errorNotFound();
}
return $this->response()->data($item);
}
InternalRequests::get('api/v1/posts'); // get al posts
InternalRequests::get('api/v1/posts/123'); // get post with id 123
InternalRequests::post('api/v1/posts', ['name' => 'Mark', 'age' => 31]); // add post
InternalRequests::put('api/v1/posts/123', ['age' => 32]); // change post with id 123
InternalRequests::delete('api/v1/posts/123'); // delete post with id 123
bash
composer dump-autoload
bash
php artisan vendor:publish
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.