onlime/laravel-bexio-api-client
Composer 安装命令:
composer require onlime/laravel-bexio-api-client
包简介
Client library for Bexio API using Laravel HTTP Client
README 文档
README
The bexio API Client Library enables you to work with the bexio API. This is a wrapper around onlime/bexio-api-client for easier Laravel integration using Laravel HTTP Client. You could use this in combination with my zero-configuration Laravel HTTP Client Global Logger for detailed request/response logging.
See onlime/bexio-api-client README and the official bexio API documentation for more information how to use the API.
Installation
You can use Composer to integrate the library into your Laravel project:
$ composer require onlime/laravel-bexio-api-client
Sample Usage
NOTE: I am just documenting Laravel project integration here. Please consult the onlime/bexio-api-client README for Bexio API Client library documentation.
I recommend to make this thing configurable in config/bexio.php:
<?php return [ /* |-------------------------------------------------------------------------- | Bexio API Credentials |-------------------------------------------------------------------------- */ 'api' => [ 'clientId' => env('BEXIO_API_CLIENT_ID', 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'), 'clientSecret' => env('BEXIO_API_CLIENT_SECRET', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ), 'tokensFile' => env('BEXIO_API_TOKENS_FILE', 'bexio_client_tokens.json'), 'scopes' => explode(' ', env('BEXIO_API_SCOPES', 'openid profile contact_edit offline_access kb_invoice_edit article_edit note_edit' )), ], ];
Put your Bexio API credentials from Bexio Developer Portal into your .env:
BEXIO_API_CLIENT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx BEXIO_API_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Create some secure storage to store the client (access and refresh) tokens, config/filesystems.php:
'disks' => [ // ... 'secure' => [ 'driver' => 'local', 'root' => storage_path('app/secure'), 'visibility' => 'private', 'throw' => false, ],
You could then define these two routes in your routes/web.php:
GET /admin/bexio/auth– authenticate against Bexio and generate your access and refresh tokensGET /admin/bexio/demo– demo page to test Bexio API with the previously generated access token
// routes/web.php <?php Route::middleware('auth')->group(function () { Route::group(['prefix' => 'admin'], function () { Route::controller(BexioController::class)->prefix('bexio')->group(function () { Route::redirect('/', '/admin/bexio/auth'); Route::get('/auth', 'authenticate')->name('bexio.auth'); Route::get('/demo', 'demo')->name('bexio.demo'); }); }); });
WARNING: Make sure you protect those rules and only make it available to your admin users!
Now create the controller, php artisan make:controller BexioController:
<?php namespace App\Http\Controllers; use Bexio\Resource\Contact as BexioContact; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; use Inertia\Inertia; use LaravelBexio\Client; class BexioController extends Controller { public function authenticate(Request $request) { $client = $this->getBexioClient(); $client->authenticate(config('bexio.api.scopes'), route('bexio.auth')); $client->persistTokens($this->getTokensFile()); return view('bexio.auth'); } public function demo(Request $request) { $client = $this->getBexioClient(); $client->loadTokens($this->getTokensFile()); return view('bexio.demo', [ 'contacts' => (new BexioContact($client))->getContacts(), ]); } protected function getBexioClient(): Client { return new Client( config('bexio.api.clientId'), config('bexio.api.clientSecret') ); } protected function getTokensFile(): string { return Storage::disk('secure')->path(config('bexio.api.tokensFile')); } }
NOTE: Make sure you add http://localhost:8080/admin/bexio/auth to the redirect URLs in Bexio Developer Portal
Now fire up your application:
$ php artisan serve
Then, access the Bexio authentication page:
This will ask you to confirm the requested scopes and you will need to login with your Bexio credentials in case you haven't done this yet.
Once you have authenticated, you'll see the contents of the bexio.auth view, which could display some confirmation message and ask you to proceed to the demo page. The demo page on http://localhost:8080/admin/bexio/demo will then use the Bexio API client tokens which were stored in <project-root>/storage/app/secure/bexio_client_tokens.json, and display all Bexio contacts (as an example, to verify all is working).
Authors
Author of this awesome package is Philip Iezzi (Onlime GmbH).
License
This package is licenced under the MIT license however support is more than welcome.
onlime/laravel-bexio-api-client 适用场景与选型建议
onlime/laravel-bexio-api-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 448 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 03 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「http client」 「laravel」 「Onlime」 「bexio」 「bexio-api-client」 「bexio-api-php-client」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 onlime/laravel-bexio-api-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 onlime/laravel-bexio-api-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 onlime/laravel-bexio-api-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Mock PSR-18 HTTP client
Asynchronous MQTT client built on React
http客户端
Easily add Excepct-CT header to your project
Client for Google Directions API to add interpolated points to a route consisting of given coordinates.
统计信息
- 总下载量: 448
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2022-03-24