mattlibera/mfl-api-wrapper-laravel
Composer 安装命令:
composer require mattlibera/mfl-api-wrapper-laravel
包简介
Laravel Wrapper for MFL (MyFantasyLeague) API PHP Library
README 文档
README
Contact: matt@mattlibera.com
Introduction
This package is a Laravel wrapper for the MFL API PHP Library package, so that the MFL API PHP Library can be used in Laravel apps.
This is a work in progress. Not recommend for production apps just yet.
Installation
composer require 'mattlibera/mfl-api-wrapper-laravel'- IF RUNNING LARAVEL 5.5+, you may skip this step, as automatic package discovery will pick this up. For Laravel 5.4 and below, add
MattLibera\MflApiLaravel\ServiceProvider::class,to yourconfig/app.phpfile manually. - Run
php artisan vendor:publish --provider='MattLibera\MflApiLaravel\ServiceProvider- to publish themfl-api.phpconfig file - Set your environment credentials in your
.envfile, and set your configuration options inconfig/mfl-api.php
Note: do not use protocols (http:// or https://) for
MFL_API_HOST. Instead put your protocol (preferably https), letters only, intoMFL_API_PROTOCOL
MFL_API_PROTOCOL=
MFL_API_HOST=
MFL_API_USERNAME=
MFL_API_PASSWORD=
MFL_API_KEY=
Note that you do not need to use both the USERNAME/PASSWORD combination and the API KEY combination; you can use either one. If your app will allow others to log into MFL to take actions on leagues in their account, then you'll probably use the former. If the app will primarily be commissioner-centric, then the latter is probably fine. You can get your API key by logging into a league and then going to Help > Developer API in the menu.
Dependencies
This package has dependencies on mattlibera/mfl-api-php-library and barryvdh/laravel-debugbar (dev)
Usage
Basic Usage / Getting Started
In your code, assuming you've set your information/credentials properly in your .env file, you should be able to instantiate the MattLibera\MflApiLaravel\MflApi class, and then use any of its available methods (inherited from MattLibera\MflApi\MflApi) to make an API call.
Configuration options
Notification Mode
There are two notification options built into this library. You may flash the information on the screen as a flash message, or log it in the Laravel logs (whatever you've got set).
In the config/mfl-api.php file, notification_mode is an array. Inside, add one or both of flash and log.
If you choose to roll this into a higher-level custom notification / logging system for your app, you can leave this array empty to disable both of these methods, and then handle your own logging based on the return array from the API call (the API class returns the entire response, including response code, from every call).
As of version 0.2, no flash messaging package is included. You are free to install your own - recommend
laracasts/flashor something that implements a similar API.
Debug Mode
Requires DebugBar by Barryvdh (barryvdh\laravel-debugbar)
If you turn on Debug Mode in the config/mfl-api.php file, extra information about the call will be written to the Debugbar. This includes timing, hashed cache key, and full results from each call.
> Note: in accordance with best practices for this package, this will only work if the app environment is not set to production
Caching
For speed, adherence to rate limits, and overall performance, API call caching is built into this library. This utilizes the Laravel Cache mechanism (which, like Logs, can be set however you want in the Laravel config). You can optionally disable this by adding MFL_API_CACHING=off in your .env file.
This caching isn't fancy; it'll literally just cache the result body from the API call. Depending on what your app is going to do, you may want to take this a step further and cache into some database tables. But this is here for you, for whatever that's worth to you.
Cache TTL
The TTL of the cache is set to 10 minutes by default, but by adding MFL_API_CACHE_MINUTES=x to your .env file, you can set the cache to expire after x minutes.
Cached endpoints
Caching is performed only for specific endpoints (e.g. requests that would equate to typical GET requests). Obviously, you would not want to cache requests that are designed to actually modify information in MFL (equivalent to POST or PATCH or DELETE requests).
By default, there is a basic set of endpoints set up in config/mfl-api.php. If you would like change which endpoints are / are not cached (or add your own), simply modify the cached_endpoints array in the config file.
In MFL, an "endpoint" can be structured differently depending on the operation. In this case, we're only going to cache the 'export' operations, and so you can assume that anything listed in cached_endpoints is a command under the 'export' operation set.
Version History
0.3
- Fix for authentication so that we use the
apiprefix for the auth call but then reset the host back to whatever is in the config.
0.2.1
- PSR4
0.2
- get rid of
standaniels/flashlibrary dependency
0.1
- First real release.
.envintegration for MFL credentials- Debug mode
- Caching
mattlibera/mfl-api-wrapper-laravel 适用场景与选型建议
mattlibera/mfl-api-wrapper-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 240 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 09 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「api」 「laravel」 「Fantasy Football」 「mfl」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mattlibera/mfl-api-wrapper-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mattlibera/mfl-api-wrapper-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mattlibera/mfl-api-wrapper-laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Alfabank REST API integration
Zero-dependency raw PHP DNS resolver, domain-ownership verification, and intoDNS/MxToolbox-style diagnostics. Queries authoritative nameservers directly over sockets — never trusts the recursive cache for ownership checks.
Laravel package for Accurate Online API integration.
A lightweight plain-PHP framework for database-backed CRUD APIs.
bughq error tracking - PHP SDK
统计信息
- 总下载量: 240
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2017-09-13