tigerheck / laravel-restapi
Laravel wrapper for RestApi APIs
v1.0.2
2023-07-24 11:53 UTC
Requires
- php: ^8.0.2
This package is auto-updated.
Last update: 2024-10-24 14:43:31 UTC
README
A Laravel wrapper for RestApi API.
Install
Via Composer
$ composer require tigerheck/laravel-restapi
Configuration
Laravel RestApi requires connection configuration. To get started, you'll need to publish all vendor assets:
$ php artisan vendor:publish --provider="TigerHeck\RestApi\RestApiServiceProvider"
add Your enviroment configuraiton file
RESTAPI_BASE_URL=
RESTAPI_CLIENT_ID=
RESTAPI_SECRET_ID=
RESTAPI_URL_ACCESS_TOKEN="/connect/token"
RESTAPI_SCOPES="********"
RESTAPI_GRANT_TYPE="client_credentials"
Examples with app("restapi")->http()
GET
$response = app("restapi")->http()->get("/api/get/url", [
'param1' => $param1,
'param2' => 'param2',
]);
POST
$response = app("restapi")->http()->post("/api/post/url", [
'data1' => $data1,
'data2' => $data2,
'data3' => $data3,
]);
PUT
$response = app("restapi")->http()->put("/api/post/url/{$id}", [
'data1' => $data1,
'data2' => $data2,
'data3' => $data3,
]);
Delete
$response = app("restapi")->http()->delete("/api/delete/url/{$id}");