wetcat/fortie
Composer 安装命令:
composer require wetcat/fortie
包简介
Enable simple Fortnox integration
README 文档
README
Fortie
A simple Fortnox PHP package, including Laravel Service Provider for easy integration in Laravel.
Installation
The easiest way to install this package is through Composer.
composer require wetcat/fortie
Or add "wetcat/fortie": "^1.0" to your composer.json.
If you don't have Composer you should install it.
Laravel
In laravel the easiest way to use Fortie is to add the ServiceProvider, in config/app.php add the following line to providers array. This is needed before any artisan commands are available.
<?php return [ ... 'providers' => [ ... Wetcat\Fortie\FortieServiceProvider::class, ], ... ];
Configuration
In Laravel you can publish the config file with php artisan vendor:publish --provider="Wetcat\Fortie\FortieServiceProvider" --tag="config", after this the file should be available in app/fortie.php. Use the details provided by Fortnox when you signed up.
The Access Token is not provided when signing up, you need to get that seperately using your Auth Code and Client Secret. Read more about this process here.
The configruation file should look something like this:
<?php return [ 'default' => [ // Your specific access token 'access_token' => '<your access token>', // Your specific client secret 'client_secret' => '<your client secret>', // The type you're sending 'content_type' => 'application/json', // The type you're accepting as response 'accepts' => 'application/json', // The URL to the Fortnox API 'endpoint' => 'https://api.fortnox.se/3/', // Rate limit (number of requests per second) 'rate_limit' => 4, ], ];
Note that XML is not fully supported yet, the package can read and will attempt to translate the responses from Fortnox into XML structures, but when sending data to Fortnox it will always send in json.
Usage
When you've included the Service Provider you can then use dependency injection in your BaseController to make fortie available in all controllers.
[...] use Wetcat\Fortie\Fortie; abstract class Controller extends BaseController { use AuthorizesRequests, DispatchesJobs, ValidatesRequests; protected $fortie; public function __construct(Fortie $fortie) { $this->fortie = $fortie; } }
Just call $this->fortie->... to access Fortie.
class MyController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { dd($this->fortie->accounts()->all()); } [...] }
Of course you can also inject Fortie into any Laravel controller method to limit application wide access to Fortnox.
[...] use Wetcat\Fortie\Fortie; class MyController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Fortie $fortie) { dd($fortie->accounts()->all()); } [...] }
Non-laravel
In Laravel the ServiceProvider takes care of setting up Fortie using the configuration file, if used outside of Laravel you need to instantiate Fortie using the configuration provided by Fortnox.
$fortie = new Fortie( $endpoint, $access_token, $client_secret, $content_type, $accepts );
Access token
To get an access token (for use with your integration) you need to request it using a authroization-code.
In Laravel you can use the Artisan command to easily get the access token.
php artisan fortie:activate code=<your authorization code>
Providers
The package is set up with multiple providers, each provider is mapped towards a specific endpoint in the REST api. For example accounts are mapped to the accounts() method.
$arrayOfAccounts = $fortie->accounts()->all();
For details on the usage of all providers you should consult the Wiki.
Currently implemented providers
- Absence Transactions
- Account Charts
- Accounts
- Archive
- Article File Connections
- Articles
- Article Url Connections
- Attendance Transactions
- Company Settings
- Contract Accruals
- Contracts
- Contract Templates
- Cost Centers
- Currencies
- Customers
- Employees
- Financial Years
- Inbox
- Invoice Accruals
- Invoice Payments
- Invoices
- Labels
- Locked Period
- Modes Of Payments
- Offers
- Orders
- Predefined Accounts
- Predefined Voucher Series
- Price Lists
- Prices
- Print Templates
- Projects
- Salary Transactions
- Schedule Times
- Supplier Invoice Accruals
- Supplier Invoice External URL Connections
- Supplier Invoice File Connections
- Supplier Invoice Payments
- Supplier Invoices
- Suppliers
- Tax Reductions
- Terms Of Deliveries
- Terms Of Payments
- Trusted Email Senders
- Units
- Voucher File Connections
- Vouchers
- Voucher Series
- Way Of Deliveries
Dependencies
This package is built with the following dependencies.
Troubleshooting
If you've got troubles with cURL errors (specifically cURL error 56) you can check (this)[http://stackoverflow.com/a/26538127/388320] answer at Stackoverflow.
License
Copyright 2015 Andreas Göransson
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
wetcat/fortie 适用场景与选型建议
wetcat/fortie 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 43.69k 次下载、GitHub Stars 达 19, 最近一次更新时间为 2015 年 10 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「business」 「taxes」 「financial」 「fortie」 「Fortnox」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wetcat/fortie 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wetcat/fortie 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wetcat/fortie 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Business rules engine tools.
Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API. Updated to use Guzzle 7 for Laravel compatibility.
Laravel Package for implementing Ecommerce taxes
Vanilo Adjustments Module
PHP Countries and Currencies
PHP Countries and Currencies
统计信息
- 总下载量: 43.69k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 20
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2015-10-07