laravel-vtex maintained by daygarcia
Description
A laravel package to help you to connect to VTEX API
Author
Last update
2023/03/24 13:38
(dev-main)
License
Downloads
19
VTEX Laravel
Requirements
PHP 8 and later
Installation & Usage
Composer
To install via composer:
composer require daygarcia/laravel-vtex
Setup
The Configuration constructor takes a single argument: an array containing all configuration needed to connect to VTEX API:
<?php
// Still under development
use Illuminate\Http\Request;
use LaravelVtex\Configuration;
...
$config = new Configuration([
'app_token' => config('vtex.app_token'),
'app_key' => config('vtex.app_key'),
'store_name' => config('vtex.store_name')
]);
Getter and setter methods are available for the Configuration class. You can directly get and set app_token, app_key and store_name
Example
<?php
use LaravelVtex\Configuration;
use LaravelVtex\Api\PromotionApi;
...
public function index(Request $request)
{
$config = new Configuration([
'app_token' => config('vtex.app_token'),
'app_key' => config('vtex.app_key'),
'store_name' => config('vtex.store_name')
]);
try {
$vtex = new PromotionAndTaxesApi($config);
$response = $vtex->getAllPromotions();
return $this->success($response);
} catch (Exception $e) {
return $this->error($e->getMessage(), $e->getCode());
}
}
Documentation & Important notes
Don’t forget to check out VTEX developer website developer site
TODO
- Improve error handling