daygarcia/laravel-vtex
Composer 安装命令:
composer require daygarcia/laravel-vtex
包简介
A laravel package to help you to connect to VTEX API
README 文档
README
A package to connect to VTEX API
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
统计信息
- 总下载量: 19
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-18